diff --git a/htdocs/soc.php b/htdocs/soc.php index 22a8fe43095..5a049ed5a10 100644 --- a/htdocs/soc.php +++ b/htdocs/soc.php @@ -45,7 +45,15 @@ if ($user->societe_id > 0) $soc = new Societe($db); -if ($_POST["action"] == 'add' or $_POST["action"] == 'update') +$step=$_POST["step"]; +if ($_POST["createnextstep"]) { $step++; $_GET["action"]="create"; } +if ($_POST["createpreviousstep"]) { $step--; $_GET["action"]="create"; } +if (! $step) $step++; + +/* + * Actions + */ +if (($_POST["action"] == 'add' && (! defined(COMPANY_CREATE_TWO_STEPS) || $step == 2)) or $_POST["action"] == 'update') { $soc->nom = stripslashes($_POST["nom"]); $soc->adresse = stripslashes($_POST["adresse"]); @@ -77,7 +85,7 @@ if ($_POST["action"] == 'add' or $_POST["action"] == 'update') $soc->id = $_GET["socid"]; // doublon sur le prefix comm $no_reload = 1; - $mesg = $soc->error;//"Erreur, le prefix '".$soc->prefix_comm."' existe déjà vous devez en choisir un autre"; + $mesg = $soc->error; //"Erreur, le prefix '".$soc->prefix_comm."' existe déjà vous devez en choisir un autre"; $_GET["action"]= "edit"; } else @@ -124,8 +132,6 @@ if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user- } /** - * - * * * */ @@ -134,21 +140,22 @@ llxHeader(); $form = new Form($db); -if ($_GET["action"] == 'create') +if ($_GET["action"] == 'create' || $_POST["action"] == 'create') { if ($user->rights->societe->creer) { /* - * Fiche societe en mode création + * Fiche societe en mode création (Creation en 1 ou 2 temps selon COMPANY_CREATE_TWO_STEPS) */ $soc->fournisseur=0; if ($_GET["type"]=='f') { $soc->fournisseur=1; } if ($_GET["type"]=='c') { $soc->client=1; } if ($_GET["type"]=='p') { $soc->client=2; } + if ($_POST["nom"]) { $soc->nom=$_POST["nom"]; } print_titre($langs->trans("NewCompany")); print "
\n"; - + if ($soc->error) { print '
'; @@ -157,67 +164,112 @@ if ($_GET["action"] == 'create') } print '
'; - print ''; print ''; print ''; - print ''; - print ''; - - print ''; - print ''; + print ''; - print ''; + // On positionne pays_id, pays_code et libelle du pays choisi + $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:(defined(MAIN_INFO_SOCIETE_PAYS)?MAIN_INFO_SOCIETE_PAYS:''); + if ($soc->pays_id) { + $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$soc->pays_id; + $result=$db->query($sql); + if ($result) + { + $obj = $db->fetch_object($result); + } + else { + dolibarr_print_error($db); + } + $soc->pays_code=$obj->code; + $soc->pays=$obj->libelle; + } + + if ($step==1 && defined(COMPANY_CREATE_TWO_STEPS)) { + print ''; + + print ''; + print ''; + print ''."\n"; - print ''; - - print ''; - print ''; - - print ''; - print ''; - - print ''; - print ''; - print ''; + } + if ($step==2 || ! defined(COMPANY_CREATE_TWO_STEPS)) { + if (defined(COMPANY_CREATE_TWO_STEPS)) { + print ''; + } else { + print ''; + } + + print ''; + print ''; + + print ''; + + print ''; + print ''; + + print ''; + + print ''; + print ''; + + print ''; + print ''; + + print ''; + print ''; + print ''; print ''; - - print ''; - - print ''; - + + print ''; + + print ''; + print ''; - - print ''."\n"; + + print ''; + print ''; + print '
Vous pouvez vérifier ce numéro sur le site de la commission européenne'; + print ''; + + print ''."\n"; + + print ''."\n"; + + print ''."\n"; + + } - print ''."\n"; - - print ''."\n"; print '
'.$langs->trans('Name').'
'.$langs->trans('Address').'
'.$langs->trans('Zip').''.$langs->trans('Town').'
'.$langs->trans('Name').'
'.$langs->trans('State').''; - $form->select_departement($soc->departement_id); - print '
'.$langs->trans('Country').''; + $form->select_pays($soc->pays_id); + print '
'.$langs->trans('Country').''; - $form->select_pays($soc->pays?$soc->pays:(defined(MAIN_INFO_SOCIETE_PAYS)?MAIN_INFO_SOCIETE_PAYS:'')); - print '
'.$langs->trans('Phone').''.$langs->trans('Fax').'
'.$langs->trans('CustomerCode').'
'.$langs->trans('Web').'
'.$langs->transcountry('ProfIdSiren',$soc->pays_code).''.$langs->transcountry('ProfIdSiret',$soc->pays_code).'
'.$langs->transcountry('ProfIdApe',$soc->pays_code).' 
'.$langs->trans('Country').''; + print $soc->pays; + print ''; + print '
'.$langs->trans('Country').''; + $form->select_pays($soc->pays_id); + print '
'.$langs->trans('Address').'
'.$langs->trans('Zip').''.$langs->trans('Town').'
'.$langs->trans('State').''; + $form->select_departement($soc->departement_id,$soc->pays_code); + print '
'.$langs->trans('Phone').''.$langs->trans('Fax').'
'.$langs->trans('CustomerCode').'
'.$langs->trans('Web').'
'.$langs->transcountry('ProfId1',$soc->pays_code).''.$langs->transcountry('ProfId2',$soc->pays_code).'
'.$langs->transcountry('ProfId3',$soc->pays_code).' 
'.$langs->trans('Capital').' '.$conf->monnaie.'
Forme juridique'; - $form->select_forme_juridique($soc->forme_juridique_code); - print '
Effectif'; - $form->select_array("effectif_id",$soc->effectif_array(), $soc->effectif_id); - print '
Forme juridique'; + $form->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); + print '
Effectif'; + $form->select_array("effectif_id",$soc->effectif_array(), $soc->effectif_id); + print '
'.$langs->trans('TVAIntra').''; - - print ''; - print ''; - print '
Vous pouvez vérifier ce numéro sur le site de la commission européenne'; - print '
'.$langs->trans('ProspectCustomer').'
'.$langs->trans('ProspectCustomer').''.$langs->trans('Supplier').''."\n"; + $form->selectyesnonum("fournisseur",$soc->fournisseur); + print '
'; + if (defined(COMPANY_CREATE_TWO_STEPS)) { + print '     '; + } + print '
'.$langs->trans('Supplier').''."\n"; - $form->selectyesnonum("fournisseur",$soc->fournisseur); - print '
'."\n"; print '
'."\n"; + } } elseif ($_GET["action"] == 'edit') @@ -261,7 +313,7 @@ elseif ($_GET["action"] == 'edit') print ''.$langs->trans('Town').''; print ''.$langs->trans('State').''; - $form->select_departement($soc->departement_id); + $form->select_departement($soc->departement_id,$soc->pays_code); print ''; print ''.$langs->trans('Country').''; @@ -295,7 +347,7 @@ elseif ($_GET["action"] == 'edit') print ''.$langs->trans("Capital").' '.$conf->monnaie.''; print 'Forme juridique'; - $form->select_forme_juridique($soc->forme_juridique_code); + $form->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); print ''; print 'Effectif'; @@ -433,16 +485,16 @@ else print ''.$langs->transcountry('ProfId1',$soc->pays_code).''; // Si société FR et siren fourni, on le vérifie if ($soc->pays_code == "FR" && $soc->siren) { - if ($soc->check_siren() == 0) - { - print ''.$soc->siren.' '; - } - else - { - print ''.$soc->siren; - // Siren invalide - print " Code Siren Invalide !"; - } + if ($soc->check_siren() == 0) + { + print ''.$soc->siren.' '; + } + else + { + print ''.$soc->siren; + // Siren invalide + print " Code Siren Invalide !"; + } } else { print $soc->siren;