2004-10-20 23:06:45 +02:00
< ? php
2007-01-15 12:50:56 +01:00
/* Copyright ( C ) 2001 - 2007 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2004-02-02 04:23:46 +01:00
* Copyright ( C ) 2003 Brian Fraval < brian @ fraval . org >
2014-04-16 00:06:16 +02:00
* Copyright ( C ) 2004 - 2014 Laurent Destailleur < eldy @ users . sourceforge . net >
2005-12-02 14:16:26 +01:00
* Copyright ( C ) 2005 Eric Seigne < eric . seigne @ ryxeo . com >
2012-12-30 15:13:49 +01:00
* Copyright ( C ) 2005 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
2013-11-23 15:22:27 +01:00
* Copyright ( C ) 2008 Patrick Raguin < patrick . raguin @ auguria . net >
2014-07-03 18:47:06 +02:00
* Copyright ( C ) 2010 - 2014 Juanjo Menent < jmenent @ 2 byte . es >
2013-11-23 15:22:27 +01:00
* Copyright ( C ) 2011 - 2013 Alexandre Spangaro < alexandre . spangaro @ gmail . com >
2015-04-18 21:28:55 +02:00
* Copyright ( C ) 2015 Jean - François Ferry < jfefe @ aternatik . fr >
2015-04-18 18:11:01 +02:00
* Copyright ( C ) 2015 Marcos GarcÃa < marcosgdf @ gmail . 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
/**
2010-07-21 23:58:46 +02:00
* \file htdocs / societe / soc . 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' ;
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
2004-07-25 18:19:33 +02:00
$langs -> load ( " companies " );
2005-12-02 14:13:36 +01:00
$langs -> load ( " commercial " );
2006-02-25 01:38:31 +01:00
$langs -> load ( " bills " );
2008-11-24 20:17:09 +01:00
$langs -> load ( " banks " );
2010-02-28 20:05:01 +01:00
$langs -> load ( " users " );
2015-02-10 12:21:29 +01: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
2011-09-24 17:57:52 +02:00
$action = ( GETPOST ( 'action' ) ? GETPOST ( 'action' ) : 'view' );
2014-04-16 00:06:16 +02:00
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
2011-09-24 17:57:52 +02:00
$confirm = GETPOST ( 'confirm' );
2012-02-27 22:26:22 +01:00
$socid = GETPOST ( 'socid' , '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
2015-03-14 13:05:28 +01:00
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
$hookmanager -> initHooks ( array ( 'thirdpartycard' , 'globalcard' ));
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
2011-06-22 12:58:22 +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-05-04 22:02:54 +02:00
if ( $action == 'confirm_merge' && $confirm == 'yes' )
{
2015-04-18 18:11:01 +02:00
$errors = 0 ;
$soc_origin_id = GETPOST ( 'soc_origin' , 'int' );
$soc_origin = new Societe ( $db );
if ( $soc_origin_id < 1 ) {
$langs -> load ( 'errors' );
$langs -> load ( 'companies' );
setEventMessage ( $langs -> trans ( 'ErrorProdIdIsMandatory' , $langs -> trans ( 'MergeOriginThirdparty' )), 'errors' );
} else {
if ( ! $errors && $soc_origin -> fetch ( $soc_origin_id ) < 1 ) {
setEventMessage ( $langs -> trans ( 'ErrorRecordNotFound' ), 'errors' );
$errors ++ ;
}
if ( ! $errors ) {
$db -> begin ();
$objects = array (
'Adherent' => '/adherents/class/adherent.class.php' ,
'Societe' => '/societe/class/societe.class.php' ,
'Bookmark' => '/bookmarks/class/bookmark.class.php' ,
'Categorie' => '/categories/class/categorie.class.php' ,
'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' ,
'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 ) {
require_once DOL_DOCUMENT_ROOT . $object_file ;
if ( ! $errors && ! $object_name :: replaceThirdparty ( $db , $soc_origin -> id , $object -> id )) {
$errors ++ ;
$db -> rollback ();
}
}
//External modules should update their ones too
$hookmanager -> initHooks ( array (
'mergethirds'
));
if ( ! $errors ) {
$reshook = $hookmanager -> executeHooks ( 'replaceThirdparty' , array (
'soc_origin' => $soc_origin -> id ,
'soc_dest' => $object -> id
), $soc_dest , $action );
if ( $reshook < 0 ) {
setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
$errors ++ ;
}
}
if ( ! $errors ) {
//We finally remove the old thirdparty
2015-05-03 18:44:42 +02:00
if ( $soc_origin -> delete ( $soc_origin -> id , $user ) < 1 ) {
2015-04-18 18:11:01 +02:00
$db -> rollback ();
$errors ++ ;
}
}
}
if ( ! $errors ) {
setEventMessage ( $langs -> trans ( 'ThirdpartiesMergeSuccess' ));
$db -> commit ();
} else {
setEventMessage ( $langs -> trans ( 'ErrorsThirdpartyMerge' ), 'errors' );
}
}
}
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 );
$res = $object -> setValueFrom ( 'localtax1_value' , $value );
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 );
$res = $object -> setValueFrom ( 'localtax2_value' , $value );
2014-07-03 18:47:06 +02:00
}
2011-06-30 15:25:32 +02:00
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
2012-05-29 09:53:39 +02:00
if ( $action == 'update' )
{
$ret = $object -> fetch ( $socid );
$object -> oldcopy = dol_clone ( $object );
}
2011-09-24 22:50:57 +02:00
else $object -> canvas = $canvas ;
2011-08-19 00:25:46 +02:00
2011-07-02 16:12:44 +02:00
if ( GETPOST ( " private " ) == 1 )
2011-06-30 15:25:32 +02:00
{
2011-09-24 17:57:52 +02:00
$object -> particulier = GETPOST ( " private " );
2011-06-11 16:14:27 +02:00
2014-10-18 00:41:21 +02:00
$object -> name = dolGetFirstLastname ( GETPOST ( 'firstname' , 'alpha' ), GETPOST ( 'nom' , 'alpha' ) ? GETPOST ( 'nom' , 'alpha' ) : GETPOST ( 'name' , 'alpha' ));
2014-08-06 15:59:36 +02:00
$object -> civility_id = GETPOST ( 'civility_id' , 'int' );
2011-12-28 17:13:19 +01:00
// Add non official properties
2014-10-18 00:41:21 +02:00
$object -> name_bis = GETPOST ( 'name' , 'alpha' ) ? GETPOST ( 'name' , 'alpha' ) : GETPOST ( 'nom' , 'alpha' );
$object -> firstname = GETPOST ( 'firstname' , 'alpha' );
2011-06-30 15:25:32 +02:00
}
else
2011-06-11 16:14:27 +02:00
{
2014-10-18 00:41:21 +02:00
$object -> name = GETPOST ( 'name' , 'alpha' ) ? GETPOST ( 'name' , 'alpha' ) : GETPOST ( 'nom' , 'alpha' );
2011-06-11 16:14:27 +02:00
}
2014-10-18 00:41:21 +02:00
$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' , 'int' );
$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 );
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' );
$object -> idprof5 = GETPOST ( 'idprof5' , 'alpha' );
$object -> idprof6 = GETPOST ( 'idprof6' , 'alpha' );
$object -> prefix_comm = GETPOST ( 'prefix_comm' , 'alpha' );
$object -> code_client = GETPOST ( 'code_client' , 'alpha' );
$object -> code_fournisseur = GETPOST ( 'code_fournisseur' , 'alpha' );
$object -> capital = GETPOST ( 'capital' , 'alpha' );
$object -> barcode = GETPOST ( 'barcode' , 'alpha' );
$object -> tva_intra = GETPOST ( 'tva_intra' , 'alpha' );
$object -> tva_assuj = GETPOST ( 'assujtva_value' , 'alpha' );
$object -> status = GETPOST ( 'status' , 'alpha' );
2010-09-07 12:24:26 +02:00
2011-06-30 15:25:32 +02:00
// Local Taxes
2014-10-18 00:41:21 +02:00
$object -> localtax1_assuj = GETPOST ( 'localtax1assuj_value' , 'alpha' );
$object -> localtax2_assuj = GETPOST ( 'localtax2assuj_value' , 'alpha' );
2014-07-04 14:25:08 +02:00
2014-10-18 00:41:21 +02:00
$object -> localtax1_value = GETPOST ( 'lt1' , 'alpha' );
$object -> localtax2_value = GETPOST ( 'lt2' , 'alpha' );
2011-06-11 16:14:27 +02:00
2014-08-06 15:59:36 +02:00
$object -> forme_juridique_code = GETPOST ( 'forme_juridique_code' , 'int' );
$object -> effectif_id = GETPOST ( 'effectif_id' , 'int' );
2014-09-15 22:58:39 +02:00
$object -> typent_id = GETPOST ( 'typent_id' );
2011-06-30 15:25:32 +02:00
2014-08-06 15:59:36 +02:00
$object -> client = GETPOST ( 'client' , 'int' );
$object -> fournisseur = GETPOST ( 'fournisseur' , 'int' );
2011-06-30 15:25:32 +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-30 15:25:32 +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-02-09 17:55:43 +01:00
{
$object -> fk_incoterms = GETPOST ( 'incoterm_id' , 'int' );
$object -> location_incoterms = GETPOST ( 'location_incoterms' , 'alpha' );
}
2013-03-30 10:46:23 +01:00
// Fill array 'array_options' with data from add form
$ret = $extrafields -> setOptionalsFromPost ( $extralabels , $object );
2015-02-26 14:25:30 +01:00
if ( $ret < 0 ) $error ++ ;
2013-10-15 20:51:44 +02:00
2011-07-02 16:12:44 +02:00
if ( GETPOST ( 'deletephoto' )) $object -> logo = '' ;
else if ( ! empty ( $_FILES [ 'photo' ][ 'name' ])) $object -> logo = dol_sanitizeFileName ( $_FILES [ 'photo' ][ 'name' ]);
2011-06-11 16:14:27 +02:00
2011-06-30 15:25:32 +02:00
// Check parameters
2014-04-16 00:06:16 +02:00
if ( ! GETPOST ( " cancel " ))
2011-06-30 15:25:32 +02:00
{
2011-07-02 16:12:44 +02:00
if ( ! empty ( $object -> email ) && ! isValidEMail ( $object -> email ))
2011-06-30 15:25:32 +02:00
{
$langs -> load ( " errors " );
2011-07-02 16:12:44 +02:00
$error ++ ; $errors [] = $langs -> trans ( " ErrorBadEMail " , $object -> email );
2011-06-30 15:25:32 +02:00
$action = ( $action == 'add' ? 'create' : 'edit' );
}
2011-07-02 16:12:44 +02:00
if ( ! empty ( $object -> url ) && ! isValidUrl ( $object -> url ))
2011-06-30 15:25:32 +02:00
{
$langs -> load ( " errors " );
2011-07-02 16:12:44 +02:00
$error ++ ; $errors [] = $langs -> trans ( " ErrorBadUrl " , $object -> url );
2011-06-30 15:25:32 +02:00
$action = ( $action == 'add' ? 'create' : 'edit' );
}
2011-07-02 16:12:44 +02:00
if ( $object -> fournisseur && ! $conf -> fournisseur -> enabled )
2011-06-30 15:25:32 +02:00
{
$langs -> load ( " errors " );
$error ++ ; $errors [] = $langs -> trans ( " ErrorSupplierModuleNotEnabled " );
$action = ( $action == 'add' ? 'create' : 'edit' );
}
2014-10-31 17:46:11 +01:00
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 );
$action = ( $action == 'add' ? 'create' : 'edit' );
}
}
2013-01-26 10:35:30 +01:00
2012-12-02 11:03:23 +01:00
// We set country_id, country_code and country for the selected country
2013-10-15 20:51:44 +02:00
$object -> country_id = GETPOST ( 'country_id' ) != '' ? GETPOST ( 'country_id' ) : $mysoc -> country_id ;
2012-12-02 11:03:23 +01:00
if ( $object -> country_id )
{
$tmparray = getCountry ( $object -> country_id , 'all' );
$object -> country_code = $tmparray [ 'code' ];
$object -> country = $tmparray [ 'label' ];
2012-11-30 21:23:12 +01:00
}
2011-08-19 00:25:46 +02:00
2012-11-30 21:23:12 +01:00
// Check for duplicate or mandatory prof id
2015-02-12 13:00:22 +01:00
// Only for companies
if ( ! ( $object -> particulier || $private ))
2011-08-11 18:53:43 +02:00
{
2015-02-12 13:00:22 +01:00
for ( $i = 1 ; $i < 5 ; $i ++ )
{
$slabel = " idprof " . $i ;
$_POST [ $slabel ] = trim ( $_POST [ $slabel ]);
$vallabel = $_POST [ $slabel ];
if ( $vallabel && $object -> id_prof_verifiable ( $i ))
{
if ( $object -> id_prof_exists ( $i , $vallabel , $object -> id ))
{
$langs -> load ( " errors " );
$error ++ ; $errors [] = $langs -> transcountry ( 'ProfId' . $i , $object -> country_code ) . " " . $langs -> trans ( " ErrorProdIdAlreadyExist " , $vallabel );
$action = (( $action == 'add' || $action == 'create' ) ? 'create' : 'edit' );
}
}
2015-03-03 18:33:53 +01:00
2015-02-12 13:00:22 +01:00
$idprof_mandatory = 'SOCIETE_IDPROF' . ( $i ) . '_MANDATORY' ;
2015-03-03 18:33:53 +01:00
2015-02-12 13:00:22 +01:00
if ( ! $vallabel && ! empty ( $conf -> global -> $idprof_mandatory ))
2011-08-11 18:53:43 +02:00
{
$langs -> load ( " errors " );
2015-02-12 13:00:22 +01:00
$error ++ ;
$errors [] = $langs -> trans ( " ErrorProdIdIsMandatory " , $langs -> transcountry ( 'ProfId' . $i , $object -> country_code ));
$action = (( $action == 'add' || $action == 'create' ) ? 'create' : 'edit' );
2011-08-11 18:53:43 +02:00
}
2015-02-12 13:00:22 +01:00
}
2013-02-18 12:57:14 +01:00
}
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
{
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 );
2011-06-30 15:25:32 +02:00
if ( $result >= 0 )
2011-06-11 16:14:27 +02:00
{
2011-07-02 16:12:44 +02:00
if ( $object -> particulier )
2011-06-30 15:25:32 +02:00
{
dol_syslog ( " This thirdparty is a personal people " , LOG_DEBUG );
2013-12-20 17:03:24 +01:00
$result = $object -> create_individual ( $user );
2011-06-30 15:25:32 +02:00
if ( ! $result >= 0 )
{
2013-12-20 17:03:24 +01:00
$error = $object -> error ; $errors = $object -> errors ;
2011-06-30 15:25:32 +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
{
// Create small thumbs for company (Ratio is near 16/9)
// Used on logon for example
$imgThumbSmall = vignette ( $newfile , $maxwidthsmall , $maxheightsmall , '_small' , $quality );
// Create mini thumbs for company (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette ( $newfile , $maxwidthmini , $maxheightmini , '_mini' , $quality );
}
}
}
2011-06-11 16:14:27 +02:00
}
2013-11-23 15:22:27 +01:00
else
{
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
{
2011-07-02 16:12:44 +02:00
$error = $object -> error ; $errors = $object -> errors ;
2011-06-30 15:25:32 +02:00
}
if ( $result >= 0 )
{
$db -> commit ();
2014-04-16 00:06:16 +02:00
if ( ! empty ( $backtopage ))
{
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' )
{
2014-04-16 00:06:16 +02:00
if ( GETPOST ( " cancel " ))
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 )
{
2011-07-02 16:12:44 +02:00
$error = $object -> error ; $errors = $object -> errors ;
2011-06-11 16:14:27 +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' ]);
2011-06-11 16:14:27 +02:00
if ( $file_OK )
{
2011-06-30 15:25:32 +02:00
if ( GETPOST ( 'deletephoto' ))
2011-06-11 22:58:08 +02:00
{
2012-04-07 09:14:33 +02:00
$fileimg = $dir . '/' . $object -> logo ;
$dirthumbs = $dir . '/thumbs' ;
2011-06-30 15:25:32 +02:00
dol_delete_file ( $fileimg );
dol_delete_dir_recursive ( $dirthumbs );
}
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
{
// Create small thumbs for company (Ratio is near 16/9)
// Used on logon for example
$imgThumbSmall = vignette ( $newfile , $maxwidthsmall , $maxheightsmall , '_small' , $quality );
// Create mini thumbs for company (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette ( $newfile , $maxwidthmini , $maxheightmini , '_mini' , $quality );
}
}
}
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
{
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 ();
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
{
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-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
}
}
}
}
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
{
2012-08-31 05:58:38 +02:00
header ( " Location: " . DOL_URL_ROOT . " /societe/societe.php?delsoc= " . urlencode ( $object -> name ));
2011-06-30 15:25:32 +02:00
exit ;
}
else
{
$langs -> load ( " errors " );
2011-07-02 16:12:44 +02:00
$error = $langs -> trans ( $object -> error ); $errors = $object -> errors ;
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
{
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 14:35:22 +02:00
// Actions to send emails
2013-09-23 13:17:31 +02:00
$id = $socid ;
$actiontypecode = 'AC_OTH_AUTO' ;
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' ;
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
2011-06-30 15:25:32 +02:00
/*
* Generate document
*/
if ( $action == 'builddoc' ) // En get ou en post
2011-06-11 16:14:27 +02:00
{
2011-06-30 15:25:32 +02:00
if ( is_numeric ( GETPOST ( 'model' )))
2011-06-11 16:14:27 +02:00
{
2011-06-30 15:25:32 +02:00
$error = $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Model " ));
2011-06-11 16:14:27 +02:00
}
else
{
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/modules/societe/modules_societe.class.php' ;
2011-06-30 15:25:32 +02:00
2011-07-02 16:12:44 +02:00
$object -> fetch ( $socid );
2011-06-30 15:25:32 +02:00
// Define output language
$outputlangs = $langs ;
$newlang = '' ;
2014-10-18 00:34:08 +02:00
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang ) && GETPOST ( 'lang_id' )) $newlang = GETPOST ( 'lang_id' );
2011-06-30 15:25:32 +02:00
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang )) $newlang = $fac -> client -> default_lang ;
if ( ! empty ( $newlang ))
{
$outputlangs = new Translate ( " " , $conf );
$outputlangs -> setDefaultLang ( $newlang );
}
2013-09-06 13:25:45 +02:00
$result = thirdparty_doc_create ( $db , $object , '' , GETPOST ( 'model' , 'alpha' ), $outputlangs );
2011-06-30 15:25:32 +02:00
if ( $result <= 0 )
{
dol_print_error ( $db , $result );
exit ;
}
2011-06-11 16:14:27 +02:00
}
}
2012-06-15 11:24:09 +02:00
2012-07-02 19:30:37 +02:00
// Remove file in doc form
else if ( $action == 'remove_file' )
{
if ( $object -> fetch ( $socid ))
{
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2012-07-02 19:30:37 +02:00
$langs -> load ( " other " );
$upload_dir = $conf -> societe -> dir_output ;
$file = $upload_dir . '/' . GETPOST ( 'file' );
2012-07-29 16:11:52 +02:00
$ret = dol_delete_file ( $file , 0 , 0 , 0 , $object );
if ( $ret ) setEventMessage ( $langs -> trans ( " FileWasRemoved " , GETPOST ( 'urlfile' )));
2012-07-29 15:47:24 +02:00
else setEventMessage ( $langs -> trans ( " ErrorFailToDeleteFile " , GETPOST ( 'urlfile' )), 'errors' );
2012-07-02 19:30:37 +02:00
}
2012-06-10 17:09:10 +02:00
}
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 ))
{
$res = $object -> fetch ( $socid );
if ( $result <= 0 ) dol_print_error ( '' , $object -> error );
}
$title = $langs -> trans ( " ThirdParty " );
if ( ! empty ( $conf -> global -> MAIN_HTML_TITLE ) && preg_match ( '/thirdpartynameonly/' , $conf -> global -> MAIN_HTML_TITLE ) && $object -> name ) $title = $object -> name ;
$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 " );
if ( ! empty ( $conf -> global -> MAIN_THIRPARTY_CREATION_INDIVIDUAL ) && ! isset ( $_GET [ 'private' ]) && ! isset ( $_POST [ 'private' ])) $private = 1 ;
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
2011-07-02 16:12:44 +02:00
//if ($_GET["type"]=='cp') { $object->client=3; }
2011-08-19 00:25:46 +02:00
if ( GETPOST ( " type " ) != 'f' ) { $object -> client = 3 ; }
2011-07-02 16:12:44 +02:00
if ( GETPOST ( " type " ) == 'c' ) { $object -> client = 1 ; }
if ( GETPOST ( " type " ) == 'p' ) { $object -> client = 2 ; }
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> fournisseur -> enabled ) && ( GETPOST ( " type " ) == 'f' || GETPOST ( " type " ) == '' )) { $object -> fournisseur = 1 ; }
2011-07-02 16:12:44 +02:00
2014-10-18 00:41:21 +02:00
$object -> name = GETPOST ( 'nom' , 'alpha' );
$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 ;
2014-10-18 00:41:21 +02:00
$object -> code_client = GETPOST ( 'code_client' , 'alpha' );
2012-07-28 12:35:11 +02:00
$object -> fournisseur = GETPOST ( 'fournisseur' ) ? GETPOST ( 'fournisseur' ) : $object -> fournisseur ;
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 );
$object -> capital = GETPOST ( 'capital' , 'int' );
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
{
// Create small thumbs for company (Ratio is near 16/9)
// Used on logon for example
$imgThumbSmall = vignette ( $newfile , $maxwidthsmall , $maxheightsmall , '_small' , $quality );
// Create mini thumbs for company (Ratio is near 16/9)
// Used on menu or for setup page for example
$imgThumbMini = vignette ( $newfile , $maxwidthmini , $maxheightmini , '_mini' , $quality );
}
}
}
}
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 = " " ;
print_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>' ;
2014-07-11 19:57:51 +02:00
print '<label for="radiocompany">' ;
2014-11-28 02:05:40 +01:00
print '<input type="radio" id="radiocompany" class="flat" name="private" value="0"' . ( $private ? '' : ' checked="checked"' ) . '>' ;
2014-07-11 19:57:51 +02:00
print ' ' ;
print $langs -> trans ( " Company/Fundation " );
print '</label>' ;
2011-06-11 16:14:27 +02:00
print ' ' ;
2014-11-28 02:05:40 +01:00
print '<label for="radioprivate">' ;
2014-12-08 00:29:33 +01:00
$text = '<input type="radio" id="radioprivate" class="flat" name="private" value="1"' . ( $private ? ' checked="checked"' : '' ) . '>' ;
$text .= ' ' ;
$text .= $langs -> trans ( " Individual " );
$htmltext = $langs -> trans ( " ToCreateContactWithSameName " );
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
2011-06-11 16:14:27 +02:00
print '<form enctype="multipart/form-data" action="' . $_SERVER [ " PHP_SELF " ] . '" method="post" name="formsoc">' ;
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 . '>' ;
2011-06-11 16:14:27 +02:00
print '<input type="hidden" name="type" value=' . GETPOST ( " type " ) . '>' ;
2011-07-18 18:37:14 +02:00
print '<input type="hidden" name="LastName" value="' . $langs -> trans ( 'LastName' ) . '">' ;
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
2014-07-11 20:04:18 +02:00
print '<tr><td>' ;
2012-11-15 16:26:05 +01:00
if ( $object -> particulier || $private )
2011-06-11 16:14:27 +02:00
{
2014-07-12 12:04:39 +02:00
print '<span id="TypeName" class="fieldrequired"><label for="name">' . $langs -> trans ( 'LastName' ) . '</label></span>' ;
2011-06-11 16:14:27 +02:00
}
else
2013-11-30 02:31:17 +01:00
{
2014-07-12 12:04:39 +02:00
print '<span span id="TypeName" class="fieldrequired"><label for="name">' . $langs -> trans ( 'ThirdPartyName' ) . '</label></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"' : '' ) . '>' ;
2014-10-23 12:01:15 +02:00
print '<input type="text" size="60" maxlength="128" name="nom" 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 )
{
2014-07-11 19:57:51 +02:00
print '<tr class="individualline"><td><label for="firstname">' . $langs -> trans ( 'FirstName' ) . '</label></td>' ;
2014-10-23 12:01:15 +02:00
print '<td><input type="text" size="60" name="firstname" id="firstname" value="' . $object -> firstname . '"></td>' ;
2011-06-11 16:14:27 +02:00
print '<td colspan=2> </td></tr>' ;
2014-07-11 19:57:51 +02:00
print '<tr class="individualline"><td><label for="civility_id">' . $langs -> trans ( " UserTitle " ) . '</label></td><td>' ;
2012-02-10 10:20:05 +01:00
print $formcompany -> select_civility ( $object -> civility_id ) . '</td>' ;
2011-06-11 16:14:27 +02:00
print '<td colspan=2> </td></tr>' ;
}
// Prospect/Customer
2014-07-12 12:04:39 +02:00
print '<tr><td width="25%"><span class="fieldrequired"><label for="customerprospect">' . $langs -> trans ( 'ProspectCustomer' ) . '</label></span></td>' ;
print '<td width="25%" class="maxwidthonsmartphone"><select class="flat" name="client" id="customerprospect">' ;
2012-03-01 00:03:16 +01:00
$selected = isset ( $_POST [ 'client' ]) ? GETPOST ( 'client' ) : $object -> client ;
if ( empty ( $conf -> global -> SOCIETE_DISABLE_PROSPECTS )) print '<option value="2"' . ( $selected == 2 ? ' selected="selected"' : '' ) . '>' . $langs -> trans ( 'Prospect' ) . '</option>' ;
2013-04-14 01:04:11 +02:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_PROSPECTS ) && empty ( $conf -> global -> SOCIETE_DISABLE_CUSTOMERS )) print '<option value="3"' . ( $selected == 3 ? ' selected="selected"' : '' ) . '>' . $langs -> trans ( 'ProspectCustomer' ) . '</option>' ;
if ( empty ( $conf -> global -> SOCIETE_DISABLE_CUSTOMERS )) print '<option value="1"' . ( $selected == 1 ? ' selected="selected"' : '' ) . '>' . $langs -> trans ( 'Customer' ) . '</option>' ;
2012-03-01 00:03:16 +01:00
print '<option value="0"' . ( $selected == 0 ? ' selected="selected"' : '' ) . '>' . $langs -> trans ( 'NorProspectNorCustomer' ) . '</option>' ;
2011-06-11 16:14:27 +02:00
print '</select></td>' ;
2014-07-11 19:57:51 +02:00
print '<td width="25%"><label for="customer_code">' . $langs -> trans ( 'CustomerCode' ) . '</label></td><td width="25%">' ;
2011-06-11 16:14:27 +02:00
print '<table class="nobordernopadding"><tr><td>' ;
2011-07-02 16:12:44 +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 );
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
print '</td><td>' ;
2011-07-02 16:12:44 +02:00
$s = $modCodeClient -> getToolTip ( $langs , $object , 0 );
2011-06-11 16:14:27 +02:00
print $form -> textwithpicto ( '' , $s , 1 );
print '</td></tr></table>' ;
print '</td></tr>' ;
2012-07-28 12:35:11 +02:00
if ( ! empty ( $conf -> fournisseur -> enabled ) && ! empty ( $user -> rights -> fournisseur -> lire ))
2011-06-11 16:14:27 +02:00
{
// Supplier
print '<tr>' ;
2014-07-12 12:04:39 +02:00
print '<td><span class="fieldrequired"><label for="fournisseur">' . $langs -> trans ( 'Supplier' ) . '</label></span></td><td>' ;
2012-03-01 00:03:16 +01:00
print $form -> selectyesno ( " fournisseur " ,( isset ( $_POST [ 'fournisseur' ]) ? GETPOST ( 'fournisseur' ) : $object -> fournisseur ), 1 );
2011-06-11 16:14:27 +02:00
print '</td>' ;
2014-07-11 19:57:51 +02:00
print '<td><label for="supplier_code">' . $langs -> trans ( 'SupplierCode' ) . '</label></td><td>' ;
2011-06-11 16:14:27 +02:00
print '<table class="nobordernopadding"><tr><td>' ;
2011-07-02 16:12:44 +02:00
$tmpcode = $object -> code_fournisseur ;
2014-02-19 01:51:19 +01:00
if ( empty ( $tmpcode ) && ! empty ( $modCodeFournisseur -> code_auto )) $tmpcode = $modCodeFournisseur -> getNextValue ( $object , 1 );
2014-07-11 19:57:51 +02:00
print '<input type="text" name="code_fournisseur" id="supplier_code" size="16" 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 = $modCodeFournisseur -> getToolTip ( $langs , $object , 1 );
2011-06-11 16:14:27 +02:00
print $form -> textwithpicto ( '' , $s , 1 );
print '</td></tr></table>' ;
print '</td></tr>' ;
}
2010-09-07 12:24:26 +02:00
2011-05-06 00:19:21 +02:00
// Status
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="status">' . $langs -> trans ( 'Status' ) . '</label></td><td colspan="3">' ;
2011-05-06 00:19:21 +02:00
print $form -> selectarray ( 'status' , array ( '0' => $langs -> trans ( 'ActivityCeased' ), '1' => $langs -> trans ( 'InActivity' )), 1 );
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
{
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="barcode">' . $langs -> trans ( 'Gencod' ) . '</label></td>' ;
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
2014-07-12 12:04:39 +02:00
print '<tr><td valign="top"><label for="address">' . $langs -> trans ( 'Address' ) . '</label></td>' ;
print '<td colspan="3"><textarea name="address" id="address" cols="40" 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
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="zipcode">' . $langs -> trans ( 'Zip' ) . '</label></td><td>' ;
2013-09-20 14:34:14 +02:00
print $formcompany -> select_ziptown ( $object -> zip , 'zipcode' , array ( 'town' , 'selectcountry_id' , 'state_id' ), 6 );
2014-07-11 19:57:51 +02:00
print '</td><td><label for="town">' . $langs -> trans ( 'Town' ) . '</label></td><td>' ;
2013-09-20 14:34:14 +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
2014-07-11 19:57:51 +02:00
print '<tr><td width="25%"><label for="selectcountry_id">' . $langs -> trans ( 'Country' ) . '</label></td><td colspan="3" class="maxwidthonsmartphone">' ;
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 ))
{
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="state_id">' . $langs -> trans ( 'State' ) . '</label></td><td colspan="3" class="maxwidthonsmartphone">' ;
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
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="email">' . $langs -> trans ( 'EMail' ) . ( ! empty ( $conf -> global -> SOCIETE_MAIL_REQUIRED ) ? '*' : '' ) . '</label></td>' ;
print '<td colspan="3"><input type="text" name="email" id="email" size="32" value="' . $object -> email . '"></td></tr>' ;
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="url">' . $langs -> trans ( 'Web' ) . '</label></td>' ;
print '<td colspan="3"><input type="text" name="url" id="url" size="32" value="' . $object -> url . '"></td></tr>' ;
2013-04-28 01:12:40 +02:00
2013-11-04 21:41:36 +01:00
// Skype
if ( ! empty ( $conf -> skype -> enabled ))
{
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="skype">' . $langs -> trans ( 'Skype' ) . '</label></td>' ;
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
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="phone">' . $langs -> trans ( 'Phone' ) . '</label></td>' ;
print '<td><input type="text" name="phone" id="phone" value="' . $object -> phone . '"></td>' ;
print '<td><label for="fax">' . $langs -> trans ( 'Fax' ) . '</label></td>' ;
print '<td><input type="text" name="fax" id="fax" 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' ;
if ( empty ( $conf -> global -> $idprof_mandatory ))
2014-07-12 12:04:39 +02:00
print '<td><label for="' . $key . '">' . $idprof . '</label></td><td>' ;
2012-11-30 21:23:12 +01:00
else
2014-07-12 12:04:39 +02:00
print '<td><span class="fieldrequired"><label for="' . $key . '">' . $idprof . '</label></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
// Assujeti TVA
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="assujtva_value">' . $langs -> trans ( 'VATIsUsed' ) . '</label></td>' ;
2011-06-11 16:14:27 +02:00
print '<td>' ;
2011-11-08 10:18:45 +01:00
print $form -> selectyesno ( 'assujtva_value' , 1 , 1 ); // Assujeti par defaut en creation
2011-06-11 16:14:27 +02:00
print '</td>' ;
2014-07-11 19:57:51 +02:00
print '<td class="nowrap"><label for="intra_vat">' . $langs -> trans ( 'VATIntra' ) . '</label></td>' ;
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' ;
2014-07-11 19:57:51 +02:00
$s = '<input type="text" class="flat" name="tva_intra" id="intra_vat" size="12" maxlength="20" value="' . $object -> tva_intra . '">' ;
2011-06-11 16:14:27 +02:00
if ( empty ( $conf -> global -> MAIN_DISABLEVATCHECK ))
{
$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>' ;
2011-06-11 16:14:27 +02:00
$s = $form -> textwithpicto ( $s , $langs -> trans ( " VATIntraCheckDesc " , $langs -> trans ( " VATIntraCheck " )), 1 );
}
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>' ;
2011-06-11 22:58:08 +02:00
// Type - Size
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="typent_id">' . $langs -> trans ( " ThirdPartyType " ) . '</label></td><td>' . " \n " ;
2013-10-28 02:13:07 +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 22:58:08 +02:00
print '</td>' ;
2014-07-12 12:04:39 +02:00
print '<td><label for="effectif_id">' . $langs -> trans ( " Staff " ) . '</label></td><td>' ;
2013-10-28 02:13:07 +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 22:58:08 +02:00
print '</td></tr>' ;
// Legal Form
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="legal_form">' . $langs -> trans ( 'JuridicalStatus' ) . '</label></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
{
2014-05-04 23:46:36 +02:00
print $formcompany -> select_juridicalstatus ( $object -> forme_juridique_code , $object -> country_code );
2011-06-11 22:58:08 +02:00
}
else
{
print $countrynotdefined ;
}
print '</td></tr>' ;
// Capital
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="capital">' . $langs -> trans ( 'Capital' ) . '</label></td>' ;
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
2013-01-26 10:35:30 +01: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
2012-11-28 09:32:41 +01:00
if ( $mysoc -> localtax1_assuj == " 1 " && $mysoc -> localtax2_assuj == " 1 " )
2011-06-11 16:14:27 +02:00
{
2012-12-12 12:40:30 +01:00
print '<tr><td>' . $langs -> transcountry ( " LocalTax1IsUsed " , $mysoc -> country_code ) . '</td><td>' ;
2012-11-27 13:05:21 +01:00
print $form -> selectyesno ( 'localtax1assuj_value' , 0 , 1 );
2012-12-12 12:40:30 +01:00
print '</td><td>' . $langs -> transcountry ( " LocalTax2IsUsed " , $mysoc -> country_code ) . '</td><td>' ;
2012-11-27 13:05:21 +01:00
print $form -> selectyesno ( 'localtax2assuj_value' , 0 , 1 );
print '</td></tr>' ;
2011-06-11 16:14:27 +02:00
2012-11-27 13:05:21 +01:00
}
2012-11-28 09:32:41 +01:00
elseif ( $mysoc -> localtax1_assuj == " 1 " )
2012-11-27 13:05:21 +01:00
{
2012-12-12 12:40:30 +01:00
print '<tr><td>' . $langs -> transcountry ( " LocalTax1IsUsed " , $mysoc -> country_code ) . '</td><td colspan="3">' ;
2012-11-27 13:05:21 +01:00
print $form -> selectyesno ( 'localtax1assuj_value' , 0 , 1 );
print '</td><tr>' ;
}
2012-11-28 09:32:41 +01:00
elseif ( $mysoc -> localtax2_assuj == " 1 " )
2012-11-27 13:05:21 +01:00
{
2012-12-12 12:40:30 +01:00
print '<tr><td>' . $langs -> transcountry ( " LocalTax2IsUsed " , $mysoc -> country_code ) . '</td><td colspan="3">' ;
2012-11-27 13:05:21 +01:00
print $form -> selectyesno ( 'localtax2assuj_value' , 0 , 1 );
print '</td><tr>' ;
2011-06-11 16:14:27 +02:00
}
2014-12-08 17:51:36 +01:00
2012-07-28 12:35:11 +02:00
if ( ! empty ( $conf -> global -> MAIN_MULTILANGS ))
2011-06-11 22:58:08 +02:00
{
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="default_lang">' . $langs -> trans ( " DefaultLang " ) . '</label></td><td colspan="3" class="maxwidthonsmartphone">' . " \n " ;
2011-07-02 16:12:44 +02:00
print $formadmin -> select_language (( $object -> default_lang ? $object -> default_lang : $conf -> global -> MAIN_LANG_DEFAULT ), 'default_lang' , 0 , 0 , 1 );
2011-06-11 22:58:08 +02:00
print '</td>' ;
print '</tr>' ;
}
2011-06-11 16:14:27 +02:00
if ( $user -> rights -> societe -> client -> voir )
{
// Assign a Name
print '<tr>' ;
2014-07-11 19:57:51 +02:00
print '<td><label for="commercial_id">' . $langs -> trans ( " AllocateCommercial " ) . '</label></td>' ;
2013-11-30 02:31:17 +01:00
print '<td colspan="3" class="maxwidthonsmartphone">' ;
2012-09-14 11:34:30 +02:00
$form -> select_users (( ! empty ( $object -> commercial_id ) ? $object -> commercial_id : $user -> id ), 'commercial_id' , 1 ); // Add current user by default
2011-06-11 16:14:27 +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>' ;
print '<td><label for="incoterm_id">' . $langs -> trans ( " IncotermLabel " ) . '</label></td>' ;
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-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
2012-02-06 18:59:07 +01:00
if ( empty ( $reshook ) && ! empty ( $extrafields -> attribute_label ))
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">' ;
2014-07-11 19:57:51 +02:00
print '<td><label for="photoinput">' . $langs -> trans ( " Logo " ) . '</label></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">' ;
2011-06-11 16:14:27 +02:00
print '<input type="submit" class="button" value="' . $langs -> trans ( 'AddThirdParty' ) . '">' ;
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
2012-03-26 18:23:08 +02:00
//print_fiche_titre($langs->trans("EditCompany"));
2011-06-11 16:14:27 +02:00
if ( $socid )
{
2012-03-04 01:09:39 +01:00
$res = $object -> fetch_optionals ( $object -> id , $extralabels );
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
2012-03-26 18:23:08 +02:00
dol_fiche_head ( $head , 'card' , $langs -> trans ( " ThirdParty " ), 0 , 'company' );
2014-09-15 22:58:39 +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
2014-08-05 18:22:01 +02:00
$object -> oldcopy = dol_clone ( $object );
2014-09-15 22:58:39 +02:00
2012-07-28 12:35:11 +02:00
if ( GETPOST ( 'nom' ))
2011-06-25 21:55:36 +02:00
{
// We overwrite with values if posted
2014-10-18 00:41:21 +02:00
$object -> name = GETPOST ( 'nom' , 'alpha' );
$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 );
$object -> capital = GETPOST ( 'capital' , 'int' );
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
dol_htmloutput_errors ( $error , $errors );
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 . '">' ;
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
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
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="name"><span class="fieldrequired">' . $langs -> trans ( 'ThirdPartyName' ) . '</span></label></td>' ;
2014-10-23 12:01:15 +02:00
print '<td colspan="3"><input type="text" size="60" maxlength="128" name="nom" id="name" value="' . dol_escape_htmltag ( $object -> name ) . '" autofocus="autofocus"></td></tr>' ;
2010-09-07 12:24:26 +02: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
{
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="prefix">' . $langs -> trans ( " Prefix " ) . '</label></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
2014-07-12 12:04:39 +02:00
print '<tr><td width="25%"><span class="fieldrequired"><label for="customerprospect">' . $langs -> trans ( 'ProspectCustomer' ) . '</label></span></td>' ;
print '<td width="25%"><select class="flat" name="client" id="customerprospect">' ;
2011-07-02 16:12:44 +02:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_PROSPECTS )) print '<option value="2"' . ( $object -> client == 2 ? ' selected="selected"' : '' ) . '>' . $langs -> trans ( 'Prospect' ) . '</option>' ;
2013-04-14 01:04:11 +02:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_PROSPECTS ) && empty ( $conf -> global -> SOCIETE_DISABLE_CUSTOMERS )) print '<option value="3"' . ( $object -> client == 3 ? ' selected="selected"' : '' ) . '>' . $langs -> trans ( 'ProspectCustomer' ) . '</option>' ;
if ( empty ( $conf -> global -> SOCIETE_DISABLE_CUSTOMERS )) print '<option value="1"' . ( $object -> client == 1 ? ' selected="selected"' : '' ) . '>' . $langs -> trans ( 'Customer' ) . '</option>' ;
2011-07-02 16:12:44 +02:00
print '<option value="0"' . ( $object -> client == 0 ? ' selected="selected"' : '' ) . '>' . $langs -> trans ( 'NorProspectNorCustomer' ) . '</option>' ;
2011-06-11 16:14:27 +02:00
print '</select></td>' ;
2014-07-11 19:57:51 +02:00
print '<td width="25%"><label for="customer_code">' . $langs -> trans ( 'CustomerCode' ) . '</label></td><td width="25%">' ;
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
{
2014-07-11 19:57:51 +02:00
print '<input type="text" name="code_client" id="customer_code" size="16" value="' . $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 ;
print '<input type="hidden" name="code_client" value="' . $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 );
2011-06-11 16:14:27 +02:00
print $form -> textwithpicto ( '' , $s , 1 );
print '</td></tr></table>' ;
print '</td></tr>' ;
// Supplier
2012-09-15 11:21:22 +02:00
if ( ! empty ( $conf -> fournisseur -> enabled ) && ! empty ( $user -> rights -> fournisseur -> lire ))
2011-06-11 16:14:27 +02:00
{
print '<tr>' ;
2014-07-12 12:04:39 +02:00
print '<td><span class="fieldrequired"><label for="fournisseur">' . $langs -> trans ( 'Supplier' ) . '</label></span></td><td>' ;
2011-07-02 16:12:44 +02:00
print $form -> selectyesno ( " fournisseur " , $object -> fournisseur , 1 );
2011-06-11 16:14:27 +02:00
print '</td>' ;
2014-07-11 19:57:51 +02:00
print '<td><label for="supplier_code">' . $langs -> trans ( 'SupplierCode' ) . '</label></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_fournisseur || $object -> code_fournisseur == - 1 ) && $modCodeFournisseur -> code_auto )
2011-06-11 16:14:27 +02:00
{
2011-07-02 16:12:44 +02:00
$tmpcode = $object -> code_fournisseur ;
2014-08-05 18:28:06 +02:00
if ( empty ( $tmpcode ) && ! empty ( $object -> oldcopy -> code_fournisseur )) $tmpcode = $object -> oldcopy -> code_fournisseur ; // When there is an error to update a thirdparty, the number for supplier and customer code is kept to old value.
2014-02-19 01:51:19 +01:00
if ( empty ( $tmpcode ) && ! empty ( $modCodeFournisseur -> code_auto )) $tmpcode = $modCodeFournisseur -> getNextValue ( $object , 1 );
2014-07-11 19:57:51 +02:00
print '<input type="text" name="code_fournisseur" id="supplier_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 -> codefournisseur_modifiable ())
2011-06-11 16:14:27 +02:00
{
2014-07-11 19:57:51 +02:00
print '<input type="text" name="code_fournisseur" id="supplier_code" size="16" value="' . $object -> code_fournisseur . '" maxlength="15">' ;
2011-06-11 16:14:27 +02:00
}
else
2013-10-15 20:51:44 +02:00
{
2011-07-02 16:12:44 +02:00
print $object -> code_fournisseur ;
print '<input type="hidden" name="code_fournisseur" value="' . $object -> code_fournisseur . '">' ;
2011-06-11 16:14:27 +02:00
}
print '</td><td>' ;
2011-07-02 16:12:44 +02:00
$s = $modCodeFournisseur -> getToolTip ( $langs , $object , 1 );
2011-06-11 16:14:27 +02:00
print $form -> textwithpicto ( '' , $s , 1 );
print '</td></tr></table>' ;
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
{
2014-07-11 19:57:51 +02:00
print '<tr><td valign="top"><label for="barcode">' . $langs -> trans ( 'Gencod' ) . '</label></td>' ;
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
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="status">' . $langs -> trans ( " Status " ) . '</label></td><td colspan="3">' ;
2011-12-07 15:06:29 +01:00
print $form -> selectarray ( 'status' , array ( '0' => $langs -> trans ( 'ActivityCeased' ), '1' => $langs -> trans ( 'InActivity' )), $object -> status );
print '</td></tr>' ;
2011-06-11 16:14:27 +02:00
// Address
2014-07-12 12:04:39 +02:00
print '<tr><td valign="top"><label for="address">' . $langs -> trans ( 'Address' ) . '</label></td>' ;
print '<td colspan="3"><textarea name="address" id="address" cols="40" 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
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="zipcode">' . $langs -> trans ( 'Zip' ) . '</label></td><td>' ;
2013-09-20 14:34:14 +02:00
print $formcompany -> select_ziptown ( $object -> zip , 'zipcode' , array ( 'town' , 'selectcountry_id' , 'state_id' ), 6 );
2014-07-11 19:57:51 +02:00
print '</td><td><label for="town">' . $langs -> trans ( 'Town' ) . '</label></td><td>' ;
2013-09-20 14:34:14 +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
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="selectcountry_id">' . $langs -> trans ( 'Country' ) . '</label></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 ))
{
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="state_id">' . $langs -> trans ( 'State' ) . '</label></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
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="email">' . $langs -> trans ( 'EMail' ) . ( ! empty ( $conf -> global -> SOCIETE_MAIL_REQUIRED ) ? '*' : '' ) . '</label></td>' ;
print '<td colspan="3"><input type="text" name="email" id="email" size="32" value="' . $object -> email . '"></td></tr>' ;
print '<tr><td><label for="url">' . $langs -> trans ( 'Web' ) . '</label></td>' ;
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 ))
{
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="skype">' . $langs -> trans ( 'Skype' ) . '</label></td>' ;
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
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="phone">' . $langs -> trans ( 'Phone' ) . '</label></td>' ;
print '<td><input type="text" name="phone" id="phone" value="' . $object -> phone . '"></td>' ;
print '<td><label for="fax">' . $langs -> trans ( 'Fax' ) . '</label></td>' ;
print '<td><input type="text" name="fax" id="fax" 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' ;
if ( empty ( $conf -> global -> $idprof_mandatory ))
print '<td><label for="' . $key . '">' . $idprof . '</label></td><td>' ;
else
print '<td><span class="fieldrequired"><label for="' . $key . '">' . $idprof . '</label></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
// VAT payers
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="assjtva_value">' . $langs -> trans ( 'VATIsUsed' ) . '</label></td><td>' ;
2011-07-02 16:12:44 +02:00
print $form -> selectyesno ( 'assujtva_value' , $object -> tva_assuj , 1 );
2011-06-11 16:14:27 +02:00
print '</td>' ;
// VAT Code
2014-07-11 19:57:51 +02:00
print '<td><label for="intra_vat">' . $langs -> trans ( 'VATIntra' ) . '</label></td>' ;
2013-05-02 18:25:27 +02:00
print '<td>' ;
2014-07-11 19:57:51 +02:00
$s = '<input type="text" class="flat" name="tva_intra" id="intra_vat" size="12" 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(document.formsoc.tva_intra.value);">' . $langs -> trans ( " VATIntraCheck " ) . '</a>' ;
2011-06-11 16:14:27 +02:00
$s = $form -> textwithpicto ( $s , $langs -> trans ( " VATIntraCheckDesc " , $langs -> trans ( " VATIntraCheck " )), 1 );
}
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 ;
print '</td>' ;
print '</tr>' ;
// Local Taxes
2013-01-05 16:03:00 +01:00
//TODO: Place into a function to control showing by country or study better option
2014-07-03 18:47:06 +02:00
if ( $mysoc -> localtax1_assuj == " 1 " && $mysoc -> localtax2_assuj == " 1 " )
2011-06-11 16:14:27 +02:00
{
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="localtax1assuj_value">' . $langs -> transcountry ( " LocalTax1IsUsed " , $mysoc -> country_code ) . '</label></td><td>' ;
2012-11-27 13:05:21 +01:00
print $form -> selectyesno ( 'localtax1assuj_value' , $object -> localtax1_assuj , 1 );
2014-07-03 18:47:06 +02:00
if ( ! isOnlyOneLocalTax ( 1 ))
{
print '<span class="cblt1"> ' . $langs -> transcountry ( " Type " , $mysoc -> country_code ) . ': ' ;
$formcompany -> select_localtax ( 1 , $object -> localtax1_value , " lt1 " );
print '</span>' ;
}
2014-07-04 14:25:08 +02:00
2014-07-12 12:04:39 +02:00
print '</td><td><label for="localtax2assuj_value">' . $langs -> transcountry ( " LocalTax2IsUsed " , $mysoc -> country_code ) . '</label></td><td>' ;
2012-11-27 13:05:21 +01:00
print $form -> selectyesno ( 'localtax2assuj_value' , $object -> localtax2_assuj , 1 );
2014-07-03 18:47:06 +02:00
if ( ! isOnlyOneLocalTax ( 2 ))
2014-07-04 14:25:08 +02:00
{
2014-07-03 18:47:06 +02:00
print '<span class="cblt2"> ' . $langs -> transcountry ( " Type " , $mysoc -> country_code ) . ': ' ;
$formcompany -> select_localtax ( 2 , $object -> localtax2_value , " lt2 " );
print '</span>' ;
}
2012-11-27 13:05:21 +01:00
print '</td></tr>' ;
2011-06-11 16:14:27 +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
{
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="localtax1assuj_value">' . $langs -> transcountry ( " LocalTax1IsUsed " , $mysoc -> country_code ) . '</label></td><td colspan="3">' ;
2012-11-27 13:05:21 +01:00
print $form -> selectyesno ( 'localtax1assuj_value' , $object -> localtax1_assuj , 1 );
2014-07-03 18:47:06 +02:00
if ( ! isOnlyOneLocalTax ( 1 ))
{
print '<span class="cblt1"> ' . $langs -> transcountry ( " Type " , $mysoc -> country_code ) . ': ' ;
$formcompany -> select_localtax ( 1 , $object -> localtax1_value , " lt1 " );
print '</span>' ;
}
2012-11-27 13:05:21 +01:00
print '</td></tr>' ;
2011-06-11 16:14:27 +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
{
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="localtax2assuj_value">' . $langs -> transcountry ( " LocalTax2IsUsed " , $mysoc -> country_code ) . '</label></td><td colspan="3">' ;
2012-11-27 13:05:21 +01:00
print $form -> selectyesno ( 'localtax2assuj_value' , $object -> localtax2_assuj , 1 );
2014-07-03 18:47:06 +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>' ;
}
2012-11-27 13:05:21 +01:00
print '</td></tr>' ;
2011-06-11 16:14:27 +02:00
}
2013-01-26 10:35:30 +01:00
2011-06-11 22:58:08 +02:00
// Type - Size
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="typent_id">' . $langs -> trans ( " ThirdPartyType " ) . '</label></td><td>' ;
2013-10-28 02:13:07 +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>' ;
2014-07-12 12:04:39 +02:00
print '<td><label for="effectif_id">' . $langs -> trans ( " Staff " ) . '</label></td><td>' ;
2011-07-02 16:12:44 +02: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
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="legal_form">' . $langs -> trans ( 'JuridicalStatus' ) . '</label></td><td colspan="3">' ;
2015-04-01 21:00:51 +02:00
print $formcompany -> select_juridicalstatus ( $object -> forme_juridique_code , $object -> country_code , '' , 0 );
2011-06-11 22:58:08 +02:00
print '</td></tr>' ;
// Capital
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="capital">' . $langs -> trans ( " Capital " ) . '</label></td>' ;
print '<td colspan="3"><input type="text" name="capital" id="capital" size="10" value="' . $object -> capital . '"><font class="hideonsmartphone">' . $langs -> trans ( " Currency " . $conf -> currency ) . '</font></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
{
2014-07-11 19:57:51 +02:00
print '<tr><td><label for="default_lang">' . $langs -> trans ( " DefaultLang " ) . '</label></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
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
2012-02-06 18:59:07 +01:00
if ( empty ( $reshook ) && ! empty ( $extrafields -> attribute_label ))
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 )) {
print '<tr><td><label for="webservices_url">' . $langs -> trans ( 'WebServiceURL' ) . '</label></td>' ;
print '<td><input type="text" name="webservices_url" id="webservices_url" size="32" value="' . $object -> webservices_url . '"></td>' ;
print '<td><label for="webservices_key">' . $langs -> trans ( 'WebServiceKey' ) . '</label></td>' ;
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>' ;
print '<td><label for="incoterm_id">' . $langs -> trans ( " IncotermLabel " ) . '</label></td>' ;
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">' ;
2014-07-11 19:57:51 +02:00
print '<td><label for="photoinput">' . $langs -> trans ( " Logo " ) . '</label></td>' ;
2011-06-11 22:58:08 +02:00
print '<td colspan="3">' ;
2014-08-11 18:02:17 +02: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">' ;
2011-07-02 16:12:44 +02:00
if ( $object -> logo ) print '<tr><td><input type="checkbox" class="flat" 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>' ;
print '<br>' ;
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 " ) . '">' ;
2014-11-24 06:43:15 +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>' ;
2012-03-26 18:23:08 +02:00
dol_fiche_end ();
2011-06-11 16:14:27 +02:00
}
}
else
{
/*
* View
*/
2012-03-04 01:09:39 +01:00
$res = $object -> fetch_optionals ( $object -> id , $extralabels );
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
dol_fiche_head ( $head , 'card' , $langs -> trans ( " ThirdParty " ), 0 , 'company' );
// 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
{
2013-09-06 11:51:24 +02: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
}
dol_htmloutput_errors ( $error , $errors );
2011-12-07 15:06:29 +01:00
$showlogo = $object -> logo ;
2014-03-16 17:37:54 +01:00
$showbarcode = empty ( $conf -> barcode -> enabled ) ? 0 : 1 ;
if ( ! empty ( $conf -> global -> MAIN_USE_ADVANCED_PERMS ) && empty ( $user -> rights -> barcode -> lire_advance )) $showbarcode = 0 ;
2014-04-16 00:06:16 +02:00
2011-06-11 16:14:27 +02:00
print '<table class="border" width="100%">' ;
// Ref
/*
print '<tr><td width="25%" valign="top">' . $langs -> trans ( " Ref " ) . '</td>' ;
print '<td colspan="2">' ;
print $fuser -> id ;
print '</td>' ;
print '</tr>' ;
*/
// Name
2013-04-10 16:15:35 +02:00
print '<tr><td width="25%">' . $langs -> trans ( 'ThirdPartyName' ) . '</td>' ;
2011-05-14 00:04:52 +02:00
print '<td colspan="3">' ;
2012-07-28 21:54:36 +02:00
print $form -> showrefnav ( $object , 'socid' , '' , ( $user -> societe_id ? 0 : 1 ), 'rowid' , 'nom' );
2011-06-11 16:14:27 +02:00
print '</td>' ;
print '</tr>' ;
2011-12-07 15:06:29 +01:00
// Logo+barcode
2014-08-11 18:22:00 +02:00
$rowspan = 6 ;
2011-06-11 16:14:27 +02:00
if ( ! empty ( $conf -> global -> SOCIETE_USEPREFIX )) $rowspan ++ ;
2012-07-23 22:04:06 +02:00
if ( ! empty ( $object -> client )) $rowspan ++ ;
if ( ! empty ( $conf -> fournisseur -> enabled ) && $object -> fournisseur && ! empty ( $user -> rights -> fournisseur -> lire )) $rowspan ++ ;
2012-09-09 16:31:00 +02:00
if ( ! empty ( $conf -> barcode -> enabled )) $rowspan ++ ;
2011-06-11 16:14:27 +02:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_STATE )) $rowspan ++ ;
2011-12-07 15:06:29 +01:00
$htmllogobar = '' ;
if ( $showlogo || $showbarcode )
2011-06-11 16:14:27 +02:00
{
2011-12-07 15:06:29 +01:00
$htmllogobar .= '<td rowspan="' . $rowspan . '" style="text-align: center;" width="25%">' ;
2014-08-11 18:06:23 +02:00
if ( $showlogo ) $htmllogobar .= $form -> showphoto ( 'societe' , $object );
2011-12-07 15:06:29 +01:00
if ( $showlogo && $showbarcode ) $htmllogobar .= '<br><br>' ;
2014-08-11 18:06:23 +02:00
if ( $showbarcode ) $htmllogobar .= $form -> showbarcode ( $object );
2011-12-07 15:06:29 +01:00
$htmllogobar .= '</td>' ;
2011-06-11 16:14:27 +02:00
}
2011-12-07 15:06:29 +01:00
// Prefix
2011-06-11 16:14:27 +02:00
if ( ! empty ( $conf -> global -> SOCIETE_USEPREFIX )) // Old not used prefix field
{
2011-12-07 15:06:29 +01:00
print '<tr><td>' . $langs -> trans ( 'Prefix' ) . '</td><td colspan="' . ( 2 + (( $showlogo || $showbarcode ) ? 0 : 1 )) . '">' . $object -> prefix_comm . '</td>' ;
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>' ;
2011-12-07 15:06:29 +01:00
print $langs -> trans ( 'CustomerCode' ) . '</td><td colspan="' . ( 2 + (( $showlogo || $showbarcode ) ? 0 : 1 )) . '">' ;
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>' ;
2011-12-07 15:06:29 +01:00
print $langs -> trans ( 'SupplierCode' ) . '</td><td colspan="' . ( 2 + (( $showlogo || $showbarcode ) ? 0 : 1 )) . '">' ;
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>' ;
print $langs -> trans ( 'Gencod' ) . '</td><td colspan="' . ( 2 + (( $showlogo || $showbarcode ) ? 0 : 1 )) . '">' . $object -> barcode ;
print '</td>' ;
print $htmllogobar ; $htmllogobar = '' ;
print '</tr>' ;
2011-12-07 15:06:29 +01:00
}
2011-06-11 16:14:27 +02:00
// Status
print '<tr><td>' . $langs -> trans ( " Status " ) . '</td>' ;
2011-12-07 15:06:29 +01:00
print '<td colspan="' . ( 2 + (( $showlogo || $showbarcode ) ? 0 : 1 )) . '">' ;
2014-11-24 01:16:26 +01:00
if ( ! empty ( $conf -> use_javascript_ajax ) && $user -> rights -> societe -> creer && ! empty ( $conf -> global -> MAIN_DIRECT_STATUS_UPDATE )) {
2014-10-18 22:52:54 +02:00
print ajax_object_onoff ( $object , 'status' , 'status' , 'InActivity' , 'ActivityCeased' );
} else {
print $object -> getLibStatut ( 2 );
}
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>' ;
// Address
2011-12-07 15:06:29 +01:00
print " <tr><td valign= \" top \" > " . $langs -> trans ( 'Address' ) . '</td><td colspan="' . ( 2 + (( $showlogo || $showbarcode ) ? 0 : 1 )) . '">' ;
2011-07-02 16:12:44 +02:00
dol_print_address ( $object -> address , 'gmap' , 'thirdparty' , $object -> id );
2011-06-11 16:14:27 +02:00
print " </td></tr> " ;
// Zip / Town
2011-12-07 15:06:29 +01:00
print '<tr><td width="25%">' . $langs -> trans ( 'Zip' ) . ' / ' . $langs -> trans ( " Town " ) . '</td><td colspan="' . ( 2 + (( $showlogo || $showbarcode ) ? 0 : 1 )) . '">' ;
2012-01-18 10:52:22 +01:00
print $object -> zip . ( $object -> zip && $object -> town ? " / " : " " ) . $object -> town ;
2011-06-11 16:14:27 +02:00
print " </td> " ;
print '</tr>' ;
// Country
2013-04-25 01:13:13 +02:00
print '<tr><td>' . $langs -> trans ( " Country " ) . '</td><td colspan="' . ( 2 + (( $showlogo || $showbarcode ) ? 0 : 1 )) . '" class="nowrap">' ;
2014-01-06 17:17:57 +01:00
if ( ! empty ( $object -> country_code ))
{
2015-01-15 02:09:28 +01:00
//$img=picto_from_langcode($object->country_code);
$img = '' ;
2014-01-06 17:17:57 +01:00
if ( $object -> isInEEC ()) print $form -> textwithpicto (( $img ? $img . ' ' : '' ) . $object -> country , $langs -> trans ( " CountryIsInEEC " ), 1 , 0 );
else print ( $img ? $img . ' ' : '' ) . $object -> country ;
}
2011-06-11 16:14:27 +02:00
print '</td></tr>' ;
// State
2011-12-07 15:06:29 +01:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_STATE )) print '<tr><td>' . $langs -> trans ( 'State' ) . '</td><td colspan="' . ( 2 + (( $showlogo || $showbarcode ) ? 0 : 1 )) . '">' . $object -> state . '</td>' ;
2011-06-11 16:14:27 +02:00
// EMail
2014-08-11 18:22:00 +02:00
print '<tr><td>' . $langs -> trans ( 'EMail' ) . '</td><td colspan="' . ( 2 + (( $showlogo || $showbarcode ) ? 0 : 1 )) . '">' ;
2011-07-02 16:12:44 +02:00
print dol_print_email ( $object -> email , 0 , $object -> id , 'AC_EMAIL' );
2013-04-28 01:12:40 +02:00
print '</td></tr>' ;
2011-06-11 16:14:27 +02:00
// Web
2014-08-11 18:22:00 +02:00
print '<tr><td>' . $langs -> trans ( 'Web' ) . '</td><td colspan="' . ( 2 + (( $showlogo || $showbarcode ) ? 0 : 1 )) . '">' ;
2011-07-02 16:12:44 +02:00
print dol_print_url ( $object -> url );
2011-06-11 16:14:27 +02:00
print '</td></tr>' ;
2013-11-23 15:22:27 +01:00
2013-11-04 21:41:36 +01:00
// Skype
if ( ! empty ( $conf -> skype -> enabled ))
{
print '<tr><td>' . $langs -> trans ( 'Skype' ) . '</td><td colspan="3">' ;
print dol_print_skype ( $object -> skype , 0 , $object -> id , 'AC_SKYPE' );
print '</td></tr>' ;
}
2011-06-11 16:14:27 +02:00
2013-04-28 01:12:40 +02:00
// Phone / Fax
print '<tr><td>' . $langs -> trans ( 'Phone' ) . '</td><td style="min-width: 25%;">' . dol_print_phone ( $object -> phone , $object -> country_code , 0 , $object -> id , 'AC_TEL' ) . '</td>' ;
print '<td>' . $langs -> trans ( 'Fax' ) . '</td><td style="min-width: 25%;">' . dol_print_phone ( $object -> fax , $object -> country_code , 0 , $object -> id , 'AC_FAX' ) . '</td></tr>' ;
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
{
2012-04-05 20:33:40 +02:00
if (( $j % 2 ) == 0 ) print '<tr>' ;
print '<td>' . $idprof . '</td><td>' ;
$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>' ;
if (( $j % 2 ) == 1 ) print '</tr>' ;
$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
}
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
// VAT payers
print '<tr><td>' ;
print $langs -> trans ( 'VATIsUsed' );
print '</td><td>' ;
2011-07-02 16:12:44 +02:00
print yn ( $object -> tva_assuj );
2011-06-11 16:14:27 +02:00
print '</td>' ;
// VAT Code
2013-04-25 01:13:13 +02:00
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 ;
2012-03-14 18:25:05 +01:00
$s .= '<input type="hidden" id="tva_intra" name="tva_intra" size="12" 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>' ;
2011-06-11 16:14:27 +02:00
$s = $form -> textwithpicto ( $s , $langs -> trans ( " VATIntraCheckDesc " , $langs -> trans ( " VATIntraCheck " )), 1 );
}
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>' ;
// Local Taxes
2013-01-05 16:03:00 +01:00
//TODO: Place into a function to control showing by country or study better option
2012-11-28 09:32:41 +01:00
if ( $mysoc -> localtax1_assuj == " 1 " && $mysoc -> localtax2_assuj == " 1 " )
2011-06-11 16:14:27 +02:00
{
2012-12-12 12:40:30 +01:00
print '<tr><td>' . $langs -> transcountry ( " LocalTax1IsUsed " , $mysoc -> country_code ) . '</td><td>' ;
2012-11-27 13:05:21 +01:00
print yn ( $object -> localtax1_assuj );
2012-12-12 12:40:30 +01:00
print '</td><td>' . $langs -> transcountry ( " LocalTax2IsUsed " , $mysoc -> country_code ) . '</td><td>' ;
2012-11-27 13:05:21 +01:00
print yn ( $object -> localtax2_assuj );
print '</td></tr>' ;
2011-06-11 16:14:27 +02:00
2014-07-03 18:47:06 +02:00
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>' ;
}
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
{
2012-12-12 12:40:30 +01:00
print '<tr><td>' . $langs -> transcountry ( " LocalTax1IsUsed " , $mysoc -> country_code ) . '</td><td colspan="3">' ;
2012-11-27 13:05:21 +01:00
print yn ( $object -> localtax1_assuj );
print '</td><tr>' ;
2014-07-03 18:47:06 +02:00
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>' ;
2014-07-04 14:25:08 +02:00
2014-07-03 18:47:06 +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
{
2012-12-12 12:40:30 +01:00
print '<tr><td>' . $langs -> transcountry ( " LocalTax2IsUsed " , $mysoc -> country_code ) . '</td><td colspan="3">' ;
2013-01-05 16:03:00 +01:00
print yn ( $object -> localtax2_assuj );
print '</td><tr>' ;
2014-07-03 18:47:06 +02:00
if ( $object -> localtax2_assuj == " 1 " && ( ! isOnlyOneLocalTax ( 2 )))
{
2014-07-04 14:25:08 +02:00
2014-07-03 18:47:06 +02:00
print '<form method="post" action="' . $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id . '">' ;
print '<input type="hidden" name="action" value="set_localtax2">' ;
print '<input type="hidden" name="token" value="' . $_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>' ;
2014-07-04 14:25:08 +02:00
2014-07-03 18:47:06 +02:00
}
2013-01-05 16:03:00 +01:00
}
2014-07-03 18:47:06 +02:00
/*
2013-01-05 16:03:00 +01:00
if ( $mysoc -> country_code == 'ES' && $mysoc -> localtax2_assuj != " 1 " && ! empty ( $conf -> fournisseur -> enabled ) && $object -> fournisseur == 1 )
{
print '<tr><td>' . $langs -> transcountry ( " LocalTax2IsUsed " , $mysoc -> country_code ) . '</td><td colspan="3">' ;
2012-11-27 13:05:21 +01:00
print yn ( $object -> localtax2_assuj );
print '</td><tr>' ;
2011-06-11 16:14:27 +02:00
}
2014-07-03 18:47:06 +02:00
*/
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 ];
print '<tr><td>' . $langs -> trans ( " ThirdPartyType " ) . '</td><td>' . $object -> typent . '</td><td>' . $langs -> trans ( " Staff " ) . '</td><td>' . $object -> effectif . '</td></tr>' ;
2011-06-11 22:58:08 +02:00
// Legal
2011-07-02 16:12:44 +02:00
print '<tr><td>' . $langs -> trans ( 'JuridicalStatus' ) . '</td><td colspan="3">' . $object -> forme_juridique . '</td></tr>' ;
2011-06-11 22:58:08 +02:00
2011-06-11 16:14:27 +02:00
// Capital
print '<tr><td>' . $langs -> trans ( 'Capital' ) . '</td><td colspan="3">' ;
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' ;
2011-06-11 16:14:27 +02:00
print '<tr><td>' . $langs -> trans ( " DefaultLang " ) . '</td><td colspan="3">' ;
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">' ;
2015-02-10 10:22:38 +01:00
if ( $user -> rights -> societe -> creer ) print '<a href="' . DOL_URL_ROOT . '/societe/soc.php?socid=' . $object -> id . '&action=editincoterm">' . img_edit () . '</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' )
{
print $form -> textwithpicto ( $object -> display_incoterms (), $object -> libelle_incoterms , 1 );
}
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>' ;
}
2011-06-22 12:58:22 +02:00
// Other attributes
2012-11-03 16:51:41 +01:00
$parameters = array ( 'socid' => $socid , '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
2013-08-01 16:02:25 +02:00
print $hookmanager -> resPrint ;
2012-02-06 18:59:07 +01:00
if ( empty ( $reshook ) && ! empty ( $extrafields -> attribute_label ))
2011-06-22 12:58:22 +02:00
{
2013-03-30 18:54:51 +01:00
print $object -> showOptionals ( $extrafields );
2011-06-22 12:58:22 +02:00
}
2011-06-11 16:14:27 +02:00
// Ban
if ( empty ( $conf -> global -> SOCIETE_DISABLE_BANKACCOUNT ))
{
print '<tr><td>' ;
print '<table width="100%" class="nobordernopadding"><tr><td>' ;
print $langs -> trans ( 'RIB' );
print '<td><td align="right">' ;
2013-06-16 21:31:21 +02:00
if ( $user -> rights -> societe -> creer ) print '<a href="' . DOL_URL_ROOT . '/societe/rib.php?socid=' . $object -> id . '">' . img_edit () . '</a>' ;
else print ' ' ;
2011-06-11 16:14:27 +02:00
print '</td></tr></table>' ;
print '</td>' ;
print '<td colspan="3">' ;
2011-07-02 16:12:44 +02:00
print $object -> display_rib ();
2011-06-11 16:14:27 +02:00
print '</td></tr>' ;
}
// 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 " );
print '<tr><td width="25%" valign="top">' . $langs -> trans ( " LinkedToDolibarrMember " ) . '</td>' ;
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
{
2013-11-05 15:29:58 +01:00
print $langs -> trans ( " ThirdpartyNotLinkedToMember " );
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>' ;
dol_fiche_end ();
/*
* Actions
*/
print '<div class="tabsAction">' . " \n " ;
2014-01-24 11:15:25 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'addMoreActionsButtons' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
if ( empty ( $reshook ))
2013-10-25 09:47:17 +02:00
{
2014-01-24 11:15:25 +01:00
if ( ! empty ( $object -> email ))
{
$langs -> load ( " mails " );
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?socid=' . $object -> id . '&action=presend&mode=init">' . $langs -> trans ( 'SendMail' ) . '</a></div>' ;
}
else
2013-04-28 01:12:40 +02:00
{
2014-01-24 11:15:25 +01:00
$langs -> load ( " mails " );
2014-02-19 15:37:48 +01:00
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#" title="' . dol_escape_htmltag ( $langs -> trans ( " NoEMail " )) . '">' . $langs -> trans ( 'SendMail' ) . '</a></div>' ;
2014-01-24 11:15:25 +01:00
}
2014-02-10 00:24:20 +01:00
2014-01-24 11:15:25 +01: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
2014-01-24 11:15:25 +01:00
if ( $user -> rights -> societe -> supprimer )
{
2014-02-19 15:37:48 +01:00
if ( $conf -> use_javascript_ajax && empty ( $conf -> dol_use_jmobile )) // We can't use preloaded confirm form with jmobile
2014-01-24 11:15:25 +01:00
{
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
2011-06-11 16:14:27 +02:00
print '</div>' . " \n " ;
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-09-23 13:17:31 +02:00
if ( $action == 'presend' )
{
2014-02-19 15:33:04 +01:00
/*
* Affiche formulaire mail
*/
// By default if $action=='presend'
$titreform = 'SendMail' ;
$topicmail = '' ;
$action = 'send' ;
$modelmail = 'thirdparty' ;
print '<br>' ;
print_titre ( $langs -> trans ( $titreform ));
2014-07-04 14:25:08 +02:00
2014-06-18 09:59:15 +02:00
// Define output language
$outputlangs = $langs ;
$newlang = '' ;
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang ) && ! empty ( $_REQUEST [ 'lang_id' ]))
$newlang = $_REQUEST [ 'lang_id' ];
if ( $conf -> global -> MAIN_MULTILANGS && empty ( $newlang ))
2015-04-18 11:06:53 +02:00
$newlang = $object -> default_lang ;
2014-02-19 15:33:04 +01:00
// Cree l'objet formulaire mail
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php' ;
$formmail = new FormMail ( $db );
2014-06-18 09:59:15 +02:00
$formmail -> param [ 'langsmodels' ] = ( empty ( $newlang ) ? $langs -> defaultlang : $newlang );
2014-02-19 15:33:04 +01:00
$formmail -> fromtype = 'user' ;
$formmail -> fromid = $user -> id ;
$formmail -> fromname = $user -> getFullName ( $langs );
$formmail -> frommail = $user -> email ;
2015-05-04 22:02:54 +02:00
if ( ! empty ( $conf -> global -> MAIN_EMAIL_ADD_TRACK_ID ) && ( $conf -> global -> MAIN_EMAIL_ADD_TRACK_ID & 1 )) // If bit 1 is set
{
$formmail -> trackid = 'thi' . $object -> id ;
}
if ( ! empty ( $conf -> global -> MAIN_EMAIL_ADD_TRACK_ID ) && ( $conf -> global -> MAIN_EMAIL_ADD_TRACK_ID & 2 )) // If bit 2 is set
2015-03-03 18:33:53 +01:00
{
include DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
$formmail -> frommail = dolAddEmailTrackId ( $formmail -> frommail , 'thi' . $object -> id );
}
2014-02-19 15:33:04 +01:00
$formmail -> withfrom = 1 ;
$formmail -> withtopic = 1 ;
$liste = array ();
foreach ( $object -> thirdparty_and_contact_email_array ( 1 ) as $key => $value ) $liste [ $key ] = $value ;
$formmail -> withto = GETPOST ( 'sendto' ) ? GETPOST ( 'sendto' ) : $liste ;
$formmail -> withtofree = 0 ;
$formmail -> withtocc = $liste ;
$formmail -> withtoccc = $conf -> global -> MAIN_EMAIL_USECCC ;
$formmail -> withfile = 2 ;
$formmail -> withbody = 1 ;
$formmail -> withdeliveryreceipt = 1 ;
$formmail -> withcancel = 1 ;
// Tableau des substitutions
$formmail -> substit [ '__SIGNATURE__' ] = $user -> signature ;
$formmail -> substit [ '__PERSONALIZED__' ] = '' ;
$formmail -> substit [ '__CONTACTCIVNAME__' ] = '' ;
//Find the good contact adress
/*
$custcontact = '' ;
$contactarr = array ();
$contactarr = $object -> liste_contact ( - 1 , 'external' );
if ( is_array ( $contactarr ) && count ( $contactarr ) > 0 )
{
foreach ( $contactarr as $contact )
{
if ( $contact [ 'libelle' ] == $langs -> trans ( 'TypeContact_facture_external_BILLING' )) {
2013-04-28 00:36:49 +02:00
2014-02-19 15:33:04 +01:00
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ;
2011-06-11 16:14:27 +02:00
2014-02-19 15:33:04 +01:00
$contactstatic = new Contact ( $db );
$contactstatic -> fetch ( $contact [ 'id' ]);
$custcontact = $contactstatic -> getFullName ( $langs , 1 );
}
}
2011-06-11 16:14:27 +02:00
2014-02-19 15:33:04 +01:00
if ( ! empty ( $custcontact )) {
$formmail -> substit [ '__CONTACTCIVNAME__' ] = $custcontact ;
}
} */
2013-06-16 20:08:45 +02:00
2011-06-11 16:14:27 +02:00
2014-02-19 15:33:04 +01:00
// Tableau des parametres complementaires du post
$formmail -> param [ 'action' ] = $action ;
$formmail -> param [ 'models' ] = $modelmail ;
2015-04-18 11:06:53 +02:00
$formmail -> param [ 'models_id' ] = GETPOST ( 'modelmailselected' , 'int' );
2014-02-19 15:33:04 +01:00
$formmail -> param [ 'socid' ] = $object -> id ;
$formmail -> param [ 'returnurl' ] = $_SERVER [ " PHP_SELF " ] . '?socid=' . $object -> id ;
2012-03-15 22:37:42 +01:00
2014-02-19 15:33:04 +01:00
// Init list of files
if ( GETPOST ( " mode " ) == 'init' )
{
$formmail -> clear_attached_files ();
$formmail -> add_attached_files ( $file , basename ( $file ), dol_mimetype ( $file ));
}
2014-02-19 20:23:02 +01:00
print $formmail -> get_form ();
2013-09-23 13:17:31 +02:00
2014-02-19 15:33:04 +01:00
print '<br>' ;
2013-09-23 13:17:31 +02:00
}
else
{
2013-09-25 21:36:40 +02:00
2013-09-23 13:17:31 +02:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_BUILDDOC ))
{
2014-10-12 11:59:52 +02:00
print '<div class="fichecenter"><div class="fichehalfleft">' ;
2013-09-23 13:17:31 +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 ;
$genallowed = $user -> rights -> societe -> creer ;
$delallowed = $user -> rights -> societe -> supprimer ;
2013-09-25 21:36:40 +02:00
2013-09-23 13:17:31 +02:00
$var = true ;
2013-09-25 21:36:40 +02:00
2013-09-23 13:17:31 +02:00
$somethingshown = $formfile -> show_documents ( 'company' , $object -> id , $filedir , $urlsource , $genallowed , $delallowed , '' , 0 , 0 , 0 , 28 , 0 , '' , 0 , '' , $object -> default_lang );
2013-09-25 21:36:40 +02:00
2014-10-12 11:59:52 +02:00
print '</div><div class="fichehalfright"><div class="ficheaddleft">' ;
2013-09-25 21:36:40 +02:00
2013-09-23 13:17:31 +02:00
print '</div></div></div>' ;
2013-09-25 21:36:40 +02:00
2013-09-23 13:17:31 +02:00
print '<br>' ;
}
2013-09-25 21:36:40 +02:00
2013-09-23 13:17:31 +02:00
print '<div class="fichecenter"><br></div>' ;
2013-09-25 21:36:40 +02:00
2013-09-23 13:17:31 +02:00
// Subsidiaries list
$result = show_subsidiaries ( $conf , $langs , $db , $object );
2013-09-25 21:36:40 +02:00
2013-09-23 13:17:31 +02: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
2013-09-23 13:17:31 +02: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-25 21:36:40 +02:00
2013-09-23 13:17:31 +02:00
// Projects list
$result = show_projects ( $conf , $langs , $db , $object , $_SERVER [ " PHP_SELF " ] . '?socid=' . $object -> id );
}
2011-06-11 16:14:27 +02:00
}
2010-05-23 12:20:35 +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 ();