diff --git a/htdocs/admin/company.php b/htdocs/admin/company.php index 22d6f6a3087..78f85dbb9aa 100644 --- a/htdocs/admin/company.php +++ b/htdocs/admin/company.php @@ -18,27 +18,28 @@ */ /** - \file htdocs/admin/company.php - \ingroup company - \brief Page d'accueil de l'espace administration/configuration - \version $Id$ -*/ + * \file htdocs/admin/company.php + * \ingroup company + * \brief Page d'accueil de l'espace administration/configuration + * \version $Id$ + */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/html.formcompany.class.php"); $langs->load("admin"); $langs->load("companies"); if (!$user->admin) - accessforbidden(); +accessforbidden(); if ( (isset($_POST["action"]) && $_POST["action"] == 'update') - || (isset($_POST["action"]) && $_POST["action"] == 'updateedit') ) +|| (isset($_POST["action"]) && $_POST["action"] == 'updateedit') ) { dolibarr_set_const($db, "MAIN_INFO_SOCIETE_NOM",$_POST["nom"]); dolibarr_set_const($db, "MAIN_INFO_SOCIETE_ADRESSE",$_POST["address"]); @@ -57,7 +58,7 @@ if ( (isset($_POST["action"]) && $_POST["action"] == 'update') if (eregi('([^\\\/:]+)$',$_FILES["logo"]["name"],$reg)) { $original_file=$reg[1]; - + $isimage=image_format_supported($original_file); if ($isimage >= 0) { @@ -65,16 +66,16 @@ if ( (isset($_POST["action"]) && $_POST["action"] == 'update') if (! is_dir($conf->societe->dir_logos)) { create_exdir($conf->societe->dir_logos); - } + } if (dol_move_uploaded_file($_FILES["logo"]["tmp_name"],$conf->societe->dir_logos.'/'.$original_file,1) > 0) { dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO",$original_file); - + // Create thumbs of logo if ($isimage > 0) { $quality = 80; - + $imgThumbSmall = vignette($conf->societe->dir_logos.'/'.$original_file, 200, 100, '_small', $quality); if (eregi('([^\\\/:]+)$',$imgThumbSmall,$reg)) { @@ -82,7 +83,7 @@ if ( (isset($_POST["action"]) && $_POST["action"] == 'update') dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$imgThumbSmall); } else dolibarr_syslog($imgThumbSmall); - + // Création de la vignette de la page "Société/Institution" $imgThumbMini = vignette($conf->societe->dir_logos.'/'.$original_file, 100, 30, '_mini', $quality); if (eregi('([^\\\/:]+)$',$imgThumbMini,$reg)) @@ -102,7 +103,7 @@ if ( (isset($_POST["action"]) && $_POST["action"] == 'update') else { $message .= '
'.$langs->trans("ErrorOnlyPngJpgSupported").'
'; - } + } } } @@ -113,7 +114,7 @@ if ( (isset($_POST["action"]) && $_POST["action"] == 'update') dolibarr_set_const($db, "MAIN_INFO_APE",$_POST["ape"]); dolibarr_set_const($db, "MAIN_INFO_RCS",$_POST["rcs"]); dolibarr_set_const($db, "MAIN_INFO_TVAINTRA",$_POST["tva"]); - + dolibarr_set_const($db, "SOCIETE_FISCAL_MONTH_START",$_POST["fiscalmonthstart"]); dolibarr_set_const($db, "FACTURE_TVAOPTION",$_POST["optiontva"]); @@ -142,7 +143,7 @@ if ($_GET["action"] == 'addthumb') dolibarr_set_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$imgThumbSmall); } else dolibarr_syslog($imgThumbSmall); - + // Création de la vignette de la page "Société/Institution" $imgThumbMini = vignette($conf->societe->dir_logos.'/'.$_GET["file"], 100, 30, '_mini',80); if (image_format_supported($imgThumbSmall) >= 0 && eregi('([^\\\/:]+)$',$imgThumbMini,$reg)) @@ -155,7 +156,7 @@ if ($_GET["action"] == 'addthumb') Header("Location: ".$_SERVER["PHP_SELF"]); exit; } - else + else { $message .= '
'.$langs->trans("ErrorImageFormatNotSupported").'
'; dolibarr_syslog($langs->transnoentities("ErrorImageFormatNotSupported"),LOG_WARNING); @@ -174,12 +175,12 @@ if ($_GET["action"] == 'removelogo') dol_delete_file($logofile); dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO"); $mysoc->logo=''; - + $logosmallfile=$conf->societe->dir_logos.'/thumbs/'.$mysoc->logo_small; dol_delete_file($logosmallfile); dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL"); $mysoc->logo_small=''; - + $logominifile=$conf->societe->dir_logos.'/thumbs/'.$mysoc->logo_mini; dol_delete_file($logominifile); dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI"); @@ -193,6 +194,8 @@ if ($_GET["action"] == 'removelogo') llxHeader(); $form = new Form($db); +$formcompany = new FormCompany($db); + $countrynotdefined=''.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; print_fiche_titre($langs->trans("CompanyFundation"),'','setup'); @@ -201,442 +204,442 @@ print $langs->trans("CompanyFundationDesc")."
\n"; print "
\n"; if ((isset($_GET["action"]) && $_GET["action"] == 'edit') - || (isset($_POST["action"]) && $_POST["action"] == 'updateedit') ) +|| (isset($_POST["action"]) && $_POST["action"] == 'updateedit') ) { - /** - * Edition des paramètres - */ - - print '
'; - print ''; - $var=true; - - print ''; - print ''."\n"; - - $var=!$var; - print ''."\n"; - - $var=!$var; - print ''."\n"; - - $var=!$var; - print ''."\n"; - - $var=!$var; - print ''."\n"; - - $var=!$var; - print ''; + print '
'; - // ProfID1 - if ($langs->transcountry("ProfId1",$code_pays) != '-') - { - $var=!$var; - print ''; - } + // Identifiants de la société (propre au pays) + print '
'.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
'.$langs->trans("CompanyName").''; - print '
'.$langs->trans("CompanyAddress").''; - print '
'.$langs->trans("CompanyZip").''; - print '
'.$langs->trans("CompanyTown").''; - print '
'.$langs->trans("Country").''; - $form->select_pays($conf->global->MAIN_INFO_SOCIETE_PAYS,'pays_id',($conf->use_javascript_ajax?' onChange="company_save_refresh()"':'')); + /** + * Edition des paramètres + */ + + print ''; + print ''; + $var=true; + + print ''; + print ''."\n"; + + $var=!$var; + print ''."\n"; + + $var=!$var; + print ''."\n"; + + $var=!$var; + print ''."\n"; + + $var=!$var; + print ''."\n"; + + $var=!$var; + print ''."\n"; - - $var=!$var; - print ''."\n"; - - $var=!$var; - print ''; - print ''."\n"; - - $var=!$var; - print ''; - print ''."\n"; - - $var=!$var; - print ''; - print ''."\n"; - - $var=!$var; - print ''; - print ''."\n"; - - $var=!$var; - print ''; - print ''; + print ''."\n"; - $var=!$var; - print ''; - + $var=!$var; + print ''."\n"; + + $var=!$var; + print ''; + print ''."\n"; + + $var=!$var; + print ''; + print ''."\n"; + + $var=!$var; + print ''; + print ''."\n"; + + $var=!$var; + print ''; + print ''."\n"; + + $var=!$var; + print ''; + print ''; + + $var=!$var; + print ''; - $var=!$var; - print ''; - print ''; - - print '
'.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
'.$langs->trans("CompanyName").''; + print '
'.$langs->trans("CompanyAddress").''; + print '
'.$langs->trans("CompanyZip").''; + print '
'.$langs->trans("CompanyTown").''; + print '
'.$langs->trans("Country").''; + $form->select_pays($conf->global->MAIN_INFO_SOCIETE_PAYS,'pays_id',($conf->use_javascript_ajax?' onChange="company_save_refresh()"':'')); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - print '
'.$langs->trans("CompanyCurrency").''; - $form->select_currency($conf->global->MAIN_MONNAIE,"currency"); - print '
'.$langs->trans("Tel").''; - print '
'.$langs->trans("Fax").''; - print '
'.$langs->trans("Mail").''; - print '
'.$langs->trans("Web").''; - print '
'.$langs->trans("Gencod").''; - print '
'.$langs->trans("Logo").' (png,jpg)'; - print '
'; - print ''; - print ''; - if ($mysoc->logo_mini && file_exists($conf->societe->dir_logos.'/thumbs/'.$mysoc->logo_mini)) - { - print ''.img_delete($langs->trans("Delete")).''; - print '   '; - print ''; - } - else - { - print ''; - } - print '
'; - print '
'.$langs->trans("CompanyCurrency").''; + $form->select_currency($conf->global->MAIN_MONNAIE,"currency"); + print '
'.$langs->trans("Tel").''; + print '
'.$langs->trans("Fax").''; + print '
'.$langs->trans("Mail").''; + print '
'.$langs->trans("Web").''; + print '
'.$langs->trans("Gencod").''; + print '
'.$langs->trans("Logo").' (png,jpg)'; + print '
'; + print ''; + print ''; + if ($mysoc->logo_mini && file_exists($conf->societe->dir_logos.'/thumbs/'.$mysoc->logo_mini)) + { + print ''.img_delete($langs->trans("Delete")).''; + print '   '; + print ''; + } + else + { + print ''; + } + print '
'; + print '
'.$langs->trans("Note").''; - print '
'; - - print '
'; - - // Identifiants de la société (propre au pays) - print ''; - print ''; - $var=true; - $langs->load("companies"); - - // Recupere code pays - $code_pays=substr($langs->defaultlang,-2); // Par defaut, pays de la localisation - if ($conf->global->MAIN_INFO_SOCIETE_PAYS) - { - $sql = "SELECT code from ".MAIN_DB_PREFIX."c_pays"; - $sql .= " WHERE rowid = ".$conf->global->MAIN_INFO_SOCIETE_PAYS; - $resql=$db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - if ($obj->code) $code_pays=$obj->code; - } - else { - dolibarr_print_error($db); - } - } + $var=!$var; + print ''; + print ''; - // Capital - $var=!$var; - print ''; + print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'.$langs->trans("Note").''; + print '
'.$langs->trans("Capital").''; - print '
'; - // Forme juridique - $var=!$var; - print '
'.$langs->trans("JuridicalStatus").''; - if ($conf->global->MAIN_INFO_SOCIETE_PAYS) - { - $form->select_forme_juridique($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,$code_pays); - } - else - { - print $countrynotdefined; - } - print '
'.$langs->transcountry("ProfId1",$code_pays).''; - if ($conf->global->MAIN_INFO_SOCIETE_PAYS) - { - print ''; - } - else - { - print $countrynotdefined; - } - print '
'; + print ''; + $var=true; - // ProfId2 - if ($langs->transcountry("ProfId2",$code_pays) != '-') - { - $var=!$var; - print ''; - } + $langs->load("companies"); - // ProfId3 - if ($langs->transcountry("ProfId3",$code_pays) != '-') - { - $var=!$var; - print ''; - } + // Recupere code pays + $code_pays=substr($langs->defaultlang,-2); // Par defaut, pays de la localisation + if ($conf->global->MAIN_INFO_SOCIETE_PAYS) + { + $sql = "SELECT code from ".MAIN_DB_PREFIX."c_pays"; + $sql .= " WHERE rowid = ".$conf->global->MAIN_INFO_SOCIETE_PAYS; + $resql=$db->query($sql); + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj->code) $code_pays=$obj->code; + } + else { + dolibarr_print_error($db); + } + } - // ProfId4 - if ($langs->transcountry("ProfId4",$code_pays) != '-') - { - $var=!$var; - print ''; - } + // Capital + $var=!$var; + print ''; - // TVA Intra - $var=!$var; - print ''; + // Forme juridique + $var=!$var; + print ''; - print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'.$langs->transcountry("ProfId2",$code_pays).''; - if ($conf->global->MAIN_INFO_SOCIETE_PAYS) - { - print ''; - } - else - { - print $countrynotdefined; - } - print '
'.$langs->transcountry("ProfId3",$code_pays).''; - if ($conf->global->MAIN_INFO_SOCIETE_PAYS) - { - print ''; - } - else - { - print $countrynotdefined; - } - print '
'.$langs->transcountry("ProfId4",$code_pays).''; - if ($conf->global->MAIN_INFO_SOCIETE_PAYS) - { - print ''; - } - else - { - print $countrynotdefined; - } - print '
'.$langs->trans("Capital").''; + print '
'.$langs->trans("VATIntra").''; - print ''; - print '
'.$langs->trans("JuridicalStatus").''; + if ($conf->global->MAIN_INFO_SOCIETE_PAYS) + { + $formcompany->select_forme_juridique($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,$code_pays); + } + else + { + print $countrynotdefined; + } + print '
'; - - - /* - * Début d'année fiscale - */ - print '
'; - print ''; - print ''; - print ''; - print "\n"; - $var=true; + // ProfID1 + if ($langs->transcountry("ProfId1",$code_pays) != '-') + { + $var=!$var; + print ''; + } - $var=!$var; - print ''; - - print "
'.$langs->trans("FiscalYearInformation").''.$langs->trans("Value").'
'.$langs->transcountry("ProfId1",$code_pays).''; + if ($conf->global->MAIN_INFO_SOCIETE_PAYS) + { + print ''; + } + else + { + print $countrynotdefined; + } + print '
'.$langs->trans("FiscalMonthStart").''; - print $form->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'fiscalmonthstart',1) . '
"; + // ProfId2 + if ($langs->transcountry("ProfId2",$code_pays) != '-') + { + $var=!$var; + print ''.$langs->transcountry("ProfId2",$code_pays).''; + if ($conf->global->MAIN_INFO_SOCIETE_PAYS) + { + print ''; + } + else + { + print $countrynotdefined; + } + print ''; + } + + // ProfId3 + if ($langs->transcountry("ProfId3",$code_pays) != '-') + { + $var=!$var; + print ''.$langs->transcountry("ProfId3",$code_pays).''; + if ($conf->global->MAIN_INFO_SOCIETE_PAYS) + { + print ''; + } + else + { + print $countrynotdefined; + } + print ''; + } + + // ProfId4 + if ($langs->transcountry("ProfId4",$code_pays) != '-') + { + $var=!$var; + print ''.$langs->transcountry("ProfId4",$code_pays).''; + if ($conf->global->MAIN_INFO_SOCIETE_PAYS) + { + print ''; + } + else + { + print $countrynotdefined; + } + print ''; + } + + // TVA Intra + $var=!$var; + print ''.$langs->trans("VATIntra").''; + print ''; + print ''; + + print ''; - /* - * Options fiscale - */ - print '
'; - print ''; - print ''; - print ''; - print ''; - print "\n"; - $var=true; - - $var=!$var; - print ""; - print '\n"; - - /* Je désactive cette option "facturation" car ce statut fiscal n'existe pas. Seul le réel et franchise existe. - Cette option ne doit donc pas etre en "exclusif" avec l'option fiscale de gestion de tva. Peut etre faut-il - une option a part qui n'entre pas en conflit avec les choix "assujéti TVA" ou "non". - $var=!$var; - print ""; - print "\n"; - */ - - $var=!$var; - print ""; - print '\n"; - - print "
'.$langs->trans("VATManagement").''.$langs->trans("Description").' 
'; - print ""; - print ""; - print "\n"; - print "
".$langs->trans("VATIsUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."
"; - print "
L'option 'facturation' est utilisée par les entreprises qui payent la TVA à facturation (vente de matériel).
'; - print ""; - print ""; - print "\n"; - print "
".$langs->trans("VATIsNotUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."
"; - print "
"; - + /* + * Début d'année fiscale + */ + print '
'; + print ''; + print ''; + print ''; + print "\n"; + $var=true; + + $var=!$var; + print ''; + + print "
'.$langs->trans("FiscalYearInformation").''.$langs->trans("Value").'
'.$langs->trans("FiscalMonthStart").''; + print $form->select_month($conf->global->SOCIETE_FISCAL_MONTH_START,'fiscalmonthstart',1) . '
"; - print '
'; - print '
'; - - print '
'; + /* + * Options fiscale + */ + print '
'; + print ''; + print ''; + print ''; + print ''; + print "\n"; + $var=true; + + $var=!$var; + print ""; + print '\n"; + + /* Je désactive cette option "facturation" car ce statut fiscal n'existe pas. Seul le réel et franchise existe. + Cette option ne doit donc pas etre en "exclusif" avec l'option fiscale de gestion de tva. Peut etre faut-il + une option a part qui n'entre pas en conflit avec les choix "assujéti TVA" ou "non". + $var=!$var; + print ""; + print "\n"; + */ + + $var=!$var; + print ""; + print '\n"; + + print "
'.$langs->trans("VATManagement").''.$langs->trans("Description").' 
'; + print ""; + print ""; + print "\n"; + print "
".$langs->trans("VATIsUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."
"; + print "
L'option 'facturation' est utilisée par les entreprises qui payent la TVA à facturation (vente de matériel).
'; + print ""; + print ""; + print "\n"; + print "
".$langs->trans("VATIsNotUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."
"; + print "
"; + + + + print '
'; + print '
'; + + print ''; } else { - /* - * Affichage des paramètres - */ + /* + * Affichage des paramètres + */ if ($message) print $message.'
'; - - print ''; - print ''; - $var=true; - $var=!$var; - print ''; + print '
'.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
'.$langs->trans("CompanyName").'' . $conf->global->MAIN_INFO_SOCIETE_NOM . '
'; + print ''; + $var=true; - $var=!$var; - print ''; + $var=!$var; + print ''; - $var=!$var; - print ''; + $var=!$var; + print ''; - $var=!$var; - print ''; + $var=!$var; + print ''; - $var=!$var; - print ''; + $var=!$var; + print ''; - $var=!$var; - print ''; + + $var=!$var; + print ''; + print ''; - $var=!$var; - print ''; + $var=!$var; + print ''; - $var=!$var; - print ''; + $var=!$var; + print ''; - $var=!$var; - print ''; + $var=!$var; + print ''; - $var=!$var; - print ''; + $var=!$var; + print ''; - $var=!$var; - print ''; + $var=!$var; + print ''; - $var=!$var; - print '
'.$langs->trans("CompanyInfo").''.$langs->trans("Value").'
'.$langs->trans("CompanyAddress").'' . nl2br($conf->global->MAIN_INFO_SOCIETE_ADRESSE) . '
'.$langs->trans("CompanyName").'' . $conf->global->MAIN_INFO_SOCIETE_NOM . '
'.$langs->trans("CompanyZip").'' . $conf->global->MAIN_INFO_SOCIETE_CP . '
'.$langs->trans("CompanyAddress").'' . nl2br($conf->global->MAIN_INFO_SOCIETE_ADRESSE) . '
'.$langs->trans("CompanyTown").'' . $conf->global->MAIN_INFO_SOCIETE_VILLE . '
'.$langs->trans("CompanyZip").'' . $conf->global->MAIN_INFO_SOCIETE_CP . '
'.$langs->trans("CompanyCountry").''; - print getCountryLabel($conf->global->MAIN_INFO_SOCIETE_PAYS,1); - print '
'.$langs->trans("CompanyTown").'' . $conf->global->MAIN_INFO_SOCIETE_VILLE . '
'.$langs->trans("CompanyCurrency").''; - print currency_name($conf->global->MAIN_MONNAIE,1); + $var=!$var; + print '
'.$langs->trans("CompanyCountry").''; + print getCountryLabel($conf->global->MAIN_INFO_SOCIETE_PAYS,1); + print '
'.$langs->trans("CompanyCurrency").''; + print currency_name($conf->global->MAIN_MONNAIE,1); print ' ('.$conf->global->MAIN_MONNAIE.')'; - print '
'.$langs->trans("Tel").'' . $conf->global->MAIN_INFO_SOCIETE_TEL . '
'.$langs->trans("Tel").'' . $conf->global->MAIN_INFO_SOCIETE_TEL . '
'.$langs->trans("Fax").'' . $conf->global->MAIN_INFO_SOCIETE_FAX . '
'.$langs->trans("Fax").'' . $conf->global->MAIN_INFO_SOCIETE_FAX . '
'.$langs->trans("Mail").'' . dol_print_email($conf->global->MAIN_INFO_SOCIETE_MAIL) . '
'.$langs->trans("Mail").'' . dol_print_email($conf->global->MAIN_INFO_SOCIETE_MAIL) . '
'.$langs->trans("Web").'' . dol_print_url($conf->global->MAIN_INFO_SOCIETE_WEB) . '
'.$langs->trans("Web").'' . dol_print_url($conf->global->MAIN_INFO_SOCIETE_WEB) . '
'.$langs->trans("Gencod").'' . $conf->global->MAIN_INFO_SOCIETE_GENCOD . '
'.$langs->trans("Gencod").'' . $conf->global->MAIN_INFO_SOCIETE_GENCOD . '
'.$langs->trans("Logo").''; - - print ''; + print ''; - $var=!$var; - print ''; + $var=!$var; + print ''; - print '
'; - print $mysoc->logo; - print ''; - - // On propose la génération de la vignette si elle n'existe pas - if (!is_file($conf->societe->dir_logos.'/thumbs/'.$mysoc->logo_mini) && eregi('(\.jpg|\.jpeg|\.png)$',$mysoc->logo)) - { - print 'logo).'">'.img_refresh($langs->trans('GenerateThumb')).'  '; - } - else if ($mysoc->logo_mini && is_file($conf->societe->dir_logos.'/thumbs/'.$mysoc->logo_mini)) - { - print ''; - } - else - { - print ''; - } + $var=!$var; + print '
'.$langs->trans("Logo").''; + + print '
'; + print $mysoc->logo; + print ''; + + // On propose la génération de la vignette si elle n'existe pas + if (!is_file($conf->societe->dir_logos.'/thumbs/'.$mysoc->logo_mini) && eregi('(\.jpg|\.jpeg|\.png)$',$mysoc->logo)) + { + print 'logo).'">'.img_refresh($langs->trans('GenerateThumb')).'  '; + } + else if ($mysoc->logo_mini && is_file($conf->societe->dir_logos.'/thumbs/'.$mysoc->logo_mini)) + { + print ''; + } + else + { + print ''; + } print '
'; - print '
'.$langs->trans("Note").'' . nl2br($conf->global->MAIN_INFO_SOCIETE_NOTE) . '
'.$langs->trans("Note").'' . nl2br($conf->global->MAIN_INFO_SOCIETE_NOTE) . '
'; + print '
'; - - print '
'; - - // Identifiants de la société (propre au pays) + print '
'; + + + // Identifiants de la société (propre au pays) print '
'; - print ''; - print ''; - $var=true; + print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'; + print ''; + $var=true; - // Recupere code pays - $code_pays=substr($langs->defaultlang,-2); // Par defaut, pays de la localisation - if ($conf->global->MAIN_INFO_SOCIETE_PAYS) - { - $sql = "SELECT code from ".MAIN_DB_PREFIX."c_pays"; - $sql .= " WHERE rowid = ".$conf->global->MAIN_INFO_SOCIETE_PAYS; - $result=$db->query($sql); - if ($result) - { - $obj = $db->fetch_object(); - if ($obj->code) $code_pays=$obj->code; - } - else { - dolibarr_print_error($db); - } - } + // Recupere code pays + $code_pays=substr($langs->defaultlang,-2); // Par defaut, pays de la localisation + if ($conf->global->MAIN_INFO_SOCIETE_PAYS) + { + $sql = "SELECT code from ".MAIN_DB_PREFIX."c_pays"; + $sql .= " WHERE rowid = ".$conf->global->MAIN_INFO_SOCIETE_PAYS; + $result=$db->query($sql); + if ($result) + { + $obj = $db->fetch_object(); + if ($obj->code) $code_pays=$obj->code; + } + else { + dolibarr_print_error($db); + } + } - // Capital - $var=!$var; - print ''; + // Capital + $var=!$var; + print ''; - // Forme juridique - $var=!$var; - print ''; + // Forme juridique + $var=!$var; + print ''; - // ProfId1 - if ($langs->transcountry("ProfId1",$code_pays) != '-') - { - $var=!$var; - print ''; - } - - // ProfId2 - if ($langs->transcountry("ProfId2",$code_pays) != '-') - { - $var=!$var; - print ''; - } - - // ProfId3 - if ($langs->transcountry("ProfId3",$code_pays) != '-') - { - $var=!$var; - print ''; - } - - // ProfId4 - if ($langs->transcountry("ProfId4",$code_pays) != '-') - { - $var=!$var; - print ''; - } - - // TVA + // ProfId1 + if ($langs->transcountry("ProfId1",$code_pays) != '-') + { + $var=!$var; + print ''; + } + + // ProfId2 + if ($langs->transcountry("ProfId2",$code_pays) != '-') + { + $var=!$var; + print ''; + } + + // ProfId3 + if ($langs->transcountry("ProfId3",$code_pays) != '-') + { + $var=!$var; + print ''; + } + + // ProfId4 + if ($langs->transcountry("ProfId4",$code_pays) != '-') + { + $var=!$var; + print ''; + } + + // TVA if ($conf->use_javascript_ajax) { print "\n"; @@ -647,10 +650,10 @@ else print ''; print "\n"; } - $var=!$var; - print ''; + $var=!$var; + print ''; print ''; print ''; - print '
'.$langs->trans("CompanyIds").''.$langs->trans("Value").'
'.$langs->trans("Capital").''; - print $conf->global->MAIN_INFO_CAPITAL . '
'.$langs->trans("Capital").''; + print $conf->global->MAIN_INFO_CAPITAL . '
'.$langs->trans("JuridicalStatus").''; - print getFormeJuridiqueLabel($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,1); - print '
'.$langs->trans("JuridicalStatus").''; + print getFormeJuridiqueLabel($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE,1); + print '
'.$langs->transcountry("ProfId1",$code_pays).''; - if ($langs->transcountry("ProfId1",$code_pays) != '-') - { - print $conf->global->MAIN_INFO_SIREN; - } - print '
'.$langs->transcountry("ProfId2",$code_pays).''; - if ($langs->transcountry("ProfId2",$code_pays) != '-') - { - print $conf->global->MAIN_INFO_SIRET; - } - print '
'.$langs->transcountry("ProfId3",$code_pays).''; - if ($langs->transcountry("ProfId3",$code_pays) != '-') - { - print $conf->global->MAIN_INFO_APE; - } - print '
'.$langs->transcountry("ProfId4",$code_pays).''; - if ($langs->transcountry("ProfId4",$code_pays) != '-') - { - print $conf->global->MAIN_INFO_RCS; - } - print '
'.$langs->transcountry("ProfId1",$code_pays).''; + if ($langs->transcountry("ProfId1",$code_pays) != '-') + { + print $conf->global->MAIN_INFO_SIREN; + } + print '
'.$langs->transcountry("ProfId2",$code_pays).''; + if ($langs->transcountry("ProfId2",$code_pays) != '-') + { + print $conf->global->MAIN_INFO_SIRET; + } + print '
'.$langs->transcountry("ProfId3",$code_pays).''; + if ($langs->transcountry("ProfId3",$code_pays) != '-') + { + print $conf->global->MAIN_INFO_APE; + } + print '
'.$langs->transcountry("ProfId4",$code_pays).''; + if ($langs->transcountry("ProfId4",$code_pays) != '-') + { + print $conf->global->MAIN_INFO_RCS; + } + print '
'.$langs->trans("VATIntra").'
'.$langs->trans("VATIntra").''; - if ($conf->global->MAIN_INFO_TVAINTRA) + if ($conf->global->MAIN_INFO_TVAINTRA) { $s=''; $code=substr($conf->global->MAIN_INFO_TVAINTRA,0,2); @@ -676,64 +679,64 @@ else print '
'; + print ''; print '
'; - + /* - * Début d'année fiscale - */ - print '
'; - print ''; - print ''; - print ''; - print "\n"; - $var=true; + * Début d'année fiscale + */ + print '
'; + print '
'.$langs->trans("FiscalYearInformation").''.$langs->trans("Value").'
'; + print ''; + print ''; + print "\n"; + $var=true; - $var=!$var; - print ''; - - print "
'.$langs->trans("FiscalYearInformation").''.$langs->trans("Value").'
'.$langs->trans("FiscalMonthStart").''; - $monthstart=(! empty($conf->global->SOCIETE_FISCAL_MONTH_START)) ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1; + $var=!$var; + print '
'.$langs->trans("FiscalMonthStart").''; + $monthstart=(! empty($conf->global->SOCIETE_FISCAL_MONTH_START)) ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1; print monthArrayOrSelected($monthstart) . '
"; - /* - * Options fiscale - */ - print '
'; - print ''; - print ''; - print ''; - print ''; - print "\n"; - $var=true; - - $var=!$var; - print ""; - print '\n"; - - $var=!$var; - print ""; - print '\n"; - - print "
'.$langs->trans("VATManagement").''.$langs->trans("Description").' 
'; - print ""; - print ""; - print "\n"; - print "
".$langs->trans("VATIsUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."
"; - print "
'; - print ""; - print ""; - print "\n"; - print "
".$langs->trans("VATIsNotUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."
"; - print "
"; - - - // Boutons d'action - print '
'; - print ''.$langs->trans("Modify").''; - print '
'; - - print '
'; + print ""; + + /* + * Options fiscale + */ + print '
'; + print ''; + print ''; + print ''; + print ''; + print "\n"; + $var=true; + + $var=!$var; + print ""; + print '\n"; + + $var=!$var; + print ""; + print '\n"; + + print "
'.$langs->trans("VATManagement").''.$langs->trans("Description").' 
'; + print ""; + print ""; + print "\n"; + print "
".$langs->trans("VATIsUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsUsedExampleFR")."
"; + print "
'; + print ""; + print ""; + print "\n"; + print "
".$langs->trans("VATIsNotUsedDesc")."
".$langs->trans("Example").': '.$langs->trans("VATIsNotUsedExampleFR")."
"; + print "
"; + + + // Boutons d'action + print '
'; + print ''.$langs->trans("Modify").''; + print '
'; + + print '
'; } $db->close(); @@ -741,13 +744,13 @@ $db->close(); llxFooter('$Date$ - $Revision$'); - + /** -* \brief Retourne le nom traduit ou code+nom d'une devise -* \param code_iso Code iso de la devise -* \param withcode 1=affiche code + nom -* \return string Nom traduit de la devise -*/ + * \brief Retourne le nom traduit ou code+nom d'une devise + * \param code_iso Code iso de la devise + * \param withcode 1=affiche code + nom + * \return string Nom traduit de la devise + */ function currency_name($code_iso,$withcode=0) { global $langs,$db; @@ -757,7 +760,7 @@ function currency_name($code_iso,$withcode=0) { return $langs->trans("Currency".$code_iso); } - + // Si pas de traduction, on consulte le libellé par défaut en table $sql = "SELECT label FROM ".MAIN_DB_PREFIX."c_currencies"; $sql.= " WHERE code_iso='".$code_iso."'"; diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index e5f43346673..c917372c262 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -28,6 +28,7 @@ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/html.formadmin.class.php"); +require_once(DOL_DOCUMENT_ROOT."/html.formcompany.class.php"); $langs->load("other"); $langs->load("admin"); @@ -715,6 +716,7 @@ function fieldList($fieldlist,$obj='') $html = new Form($db); $formadmin = new FormAdmin($db); + $formcompany = new FormCompany($db); foreach ($fieldlist as $field => $value) { @@ -730,7 +732,7 @@ function fieldList($fieldlist,$obj='') } elseif ($fieldlist[$field] == 'region') { print ''; - $html->select_region($region_id,'region'); + $formcompany->select_region($region_id,'region'); print ''; } elseif ($fieldlist[$field] == 'region_id') { diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 4f115db8b96..4dfec000e00 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -448,7 +448,7 @@ if ($_GET["action"] == 'create') } else { - $html->select_type_actions($actioncomm->type_code, "actioncode"); + $htmlactions->select_type_actions($actioncomm->type_code, "actioncode"); } print ''; diff --git a/htdocs/comm/prospect/fiche.php b/htdocs/comm/prospect/fiche.php index 06ac6c77903..7003d4db50c 100644 --- a/htdocs/comm/prospect/fiche.php +++ b/htdocs/comm/prospect/fiche.php @@ -28,6 +28,7 @@ require_once("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/prospect.class.php"); +require_once(DOL_DOCUMENT_ROOT."/html.formcompany.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php"); if ($conf->propal->enabled) require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); @@ -72,7 +73,9 @@ if ($_POST["action"] == 'setprospectlevel' && $user->rights->societe->creer) *********************************************************************************/ llxHeader(); + $form=new Form($db); +$formcompany=new FormCompany($db); if ($socid > 0) { @@ -127,12 +130,12 @@ if ($socid > 0) print ''; if ($_GET['action'] == 'editlevel') { - $form->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$societe->id,$societe->fk_prospectlevel,'prospect_level_id',1); + $formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$societe->id,$societe->fk_prospectlevel,'prospect_level_id',1); } else { print $societe->getLibLevel(); - //$html->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$objsoc->id,$objsoc->mode_reglement,'none'); + //$formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$objsoc->id,$objsoc->mode_reglement,'none'); } print ""; print ''; diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index cd67020bbcc..d1f706f9ca8 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -29,7 +29,8 @@ require('./pre.inc.php'); require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); -require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php"); +require_once(DOL_DOCUMENT_ROOT."/html.formorder.class.php"); +require_once(DOL_DOCUMENT_ROOT."/includes/modules/commande/modules_commande.php"); require_once(DOL_DOCUMENT_ROOT.'/commande/commande.class.php'); require_once(DOL_DOCUMENT_ROOT.'/actioncomm.class.php'); require_once(DOL_DOCUMENT_ROOT."/lib/order.lib.php"); @@ -837,6 +838,8 @@ llxHeader('',$langs->trans('Order'),'Commande'); $html = new Form($db); $formfile = new FormFile($db); +$formorder = new FormOrder($db); + /********************************************************************* * @@ -971,7 +974,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer) } print ''.$langs->trans('Source').''; - $html->selectSourcesCommande('','source_id',1); + $formorder->selectSourcesCommande('','source_id',1); print ''; print ''.$langs->trans('Model').''; diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index f62222d4cb6..b0c564b242f 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -32,6 +32,7 @@ require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/contact.lib.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/html.formcompany.class.php"); $langs->load("companies"); $langs->load("users"); @@ -195,6 +196,7 @@ if ($user->rights->societe->contact->creer) llxHeader(); $form = new Form($db); +$formcompany = new FormCompany($db); if ($socid) { @@ -289,7 +291,7 @@ if ($user->rights->societe->contact->creer) // Civility print ''.$langs->trans("UserTitle").''; - print $form->select_civilite($contact->civilite_id); + print $formcompany->select_civilite($contact->civilite_id); print ''; print ''.$langs->trans("PostOrFunction").''; @@ -372,7 +374,7 @@ if ($user->rights->societe->contact->creer) // Civility print ''.$langs->trans("UserTitle").''; - print $form->select_civilite($contact->civilite_id); + print $formcompany->select_civilite($contact->civilite_id); print ''; print ''.$langs->trans("PostOrFunction" ).''; diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 2582cab2019..3145a2b722c 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -20,11 +20,11 @@ */ /** - \file htdocs/fourn/commande/fiche.php - \ingroup commande - \brief Fiche de ventilation des commandes fournisseurs - \version $Id$ -*/ + \file htdocs/fourn/commande/fiche.php + \ingroup commande + \brief Fiche de ventilation des commandes fournisseurs + \version $Id$ + */ require('./pre.inc.php'); require_once(DOL_DOCUMENT_ROOT.'/includes/modules/supplier_order/modules_commandefournisseur.php'); @@ -45,15 +45,15 @@ if (!$user->rights->fournisseur->commande->lire) accessforbidden(); $socid=0; if ($user->societe_id > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->societe_id; } // Récupération de l'id de projet $projetid = 0; if ($_GET["projetid"]) { - $projetid = $_GET["projetid"]; + $projetid = $_GET["projetid"]; } $mesg=''; @@ -63,23 +63,23 @@ $mesg=''; */ if ($_POST["action"] == 'dispatch' && $user->rights->fournisseur->commande->receptionner) { - $commande = new CommandeFournisseur($db); - $commande->fetch($_GET["id"]); + $commande = new CommandeFournisseur($db); + $commande->fetch($_GET["id"]); - foreach($_POST as $key => $value) - { - if ( eregi('^product_([0-9]+)$', $key, $reg) ) + foreach($_POST as $key => $value) { + if ( eregi('^product_([0-9]+)$', $key, $reg) ) + { $prod = "product_".$reg[1]; $qty = "qty_".$reg[1]; $ent = "entrepot_".$reg[1]; $pu = "pu_".$reg[1]; $result = $commande->DispatchProduct($user, $_POST[$prod], $_POST[$qty], $_POST[$ent], $_POST[$pu]); + } } - } - Header("Location: dispatch.php?id=".$_GET["id"]); - exit; + Header("Location: dispatch.php?id=".$_GET["id"]); + exit; } @@ -96,307 +96,307 @@ $html = new Form($db); $id = $_GET['id']; if ($id > 0) { - //if ($mesg) print $mesg.'
'; - - $commande = new CommandeFournisseur($db); - if ( $commande->fetch($_GET['id']) >= 0) - { - $soc = new Societe($db); - $soc->fetch($commande->socid); - - $author = new User($db); - $author->id = $commande->user_author_id; - $author->fetch(); - - $h = 0; - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$commande->id; - $head[$h][1] = $langs->trans("OrderCard"); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$commande->id; - $head[$h][1] = $langs->trans("OrderDispatch"); - $a = $h; - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$commande->id; - $head[$h][1] = $langs->trans("Note"); - $h++; - - $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/history.php?id='.$commande->id; - $head[$h][1] = $langs->trans("OrderFollow"); - $h++; - - $title=$langs->trans("SupplierOrder"); - dolibarr_fiche_head($head, $a, $title); - - /* - * Commande - */ - print ''; - // Ref - print ''; - print ''; - print ''; - - // Fournisseur - print '"; - print ''; - print ''; - - // Statut - print ''; - print ''; - print '"; + //if ($mesg) print $mesg.'
'; - if ($commande->methode_commande_id > 0) + $commande = new CommandeFournisseur($db); + if ( $commande->fetch($_GET['id']) >= 0) { - print '"; + $soc = new Societe($db); + $soc->fetch($commande->socid); + + $author = new User($db); + $author->id = $commande->user_author_id; + $author->fetch(); + + $h = 0; + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/fiche.php?id='.$commande->id; + $head[$h][1] = $langs->trans("OrderCard"); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$commande->id; + $head[$h][1] = $langs->trans("OrderDispatch"); + $a = $h; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/note.php?id='.$commande->id; + $head[$h][1] = $langs->trans("Note"); + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/history.php?id='.$commande->id; + $head[$h][1] = $langs->trans("OrderFollow"); + $h++; + + $title=$langs->trans("SupplierOrder"); + dolibarr_fiche_head($head, $a, $title); + + /* + * Commande + */ + print '
'.$langs->trans("Ref").''.$commande->ref.'
'.$langs->trans("Supplier")."'; - print ''; - print img_object($langs->trans("ShowSupplier"),'company').' '.$soc->nom.'
'.$langs->trans("Status").''; - print $commande->getLibStatut(4); - print "
'.$langs->trans("Date").''; - - if ($commande->date_commande) - { - print dolibarr_print_date($commande->date_commande,"dayhourtext")."\n"; - } - - print ''; - if ($commande->methode_commande) - { - print "Méthode : " .$commande->methode_commande; - } - print "
'; + // Ref + print ''; + print ''; + print ''; + + // Fournisseur + print '"; + print ''; + print ''; + + // Statut + print ''; + print ''; + print '"; + + if ($commande->methode_commande_id > 0) + { + print '"; + } + + // Auteur + print ''; + print ''; + print '"; + print "
'.$langs->trans("Ref").''.$commande->ref.'
'.$langs->trans("Supplier")."'; + print ''; + print img_object($langs->trans("ShowSupplier"),'company').' '.$soc->nom.'
'.$langs->trans("Status").''; + print $commande->getLibStatut(4); + print "
'.$langs->trans("Date").''; + + if ($commande->date_commande) + { + print dolibarr_print_date($commande->date_commande,"dayhourtext")."\n"; + } + + print ''; + if ($commande->methode_commande) + { + print $langs->trans("Method")." : " .$commande->methode_commande; + } + print "
'.$langs->trans("AuthorRequest").''.$author->getNomUrl(1).''; + print " 
"; + + if ($mesg) print $mesg; + else print '
'; + + /* + * Lignes de commandes + */ + if ($commande->statut == 3 || $commande->statut == 4 || $commande->statut == 5) + { + print '
'; + print ''; + print ''; + + $sql = "SELECT cfd.fk_product, sum(cfd.qty) as qty"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd"; + $sql.= " WHERE cfd.fk_commande = ".$commande->id; + $sql.= " GROUP BY cfd.fk_product"; + + $resql = $db->query($sql); + if ($resql) + { + while ( $row = $db->fetch_row($resql) ) + { + $products_dispatched[$row[0]] = $row[1]; + } + $db->free($resql); + } + + $sql = "SELECT l.ref,l.fk_product,l.description, l.subprice, sum(l.qty) as qty"; + $sql.= ", l.rowid"; + $sql.= ", p.label"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product=p.rowid"; + $sql.= " WHERE l.fk_commande = ".$commande->id; + $sql.= " GROUP BY l.fk_product"; + $sql.= " ORDER BY l.rowid"; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + if ($num) + { + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + + $entrepot = new Entrepot($db); + + $var=true; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + // On n'affiche pas les produits personnalisés + if ($objp->fk_product) + { + $var=!$var; + print ""; + print '\n"; + + print ''; + print ''; + + print '\n"; + print ''; + print "\n"; + } + $i++; + } + $db->free($resql); + } + else + { + dolibarr_print_error($db); + } + + print "
'.$langs->trans("Description").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyDispatched").''.$langs->trans("Warehouse").''.$langs->trans("QtyDelivered").'
'; + print ''.img_object($langs->trans("ShowProduct"),'product').' '.$objp->ref.''; + print ' - '.$objp->label; + if ($objp->description) print '
'.nl2br($objp->description); + print ''; + print ''; + print "
'.$objp->qty.''.$products_dispatched[$objp->fk_product].''; + + if (sizeof($user->entrepots) === 1) + { + $uentrepot = array(); + $uentrepot[$user->entrepots[0]['id']] = $user->entrepots[0]['label']; + $html->select_array("entrepot_".$i, $uentrepot); + } + else + { + $html->select_array("entrepot_".$i, $entrepot->list_array()); + } + print "
\n"; + print "
\n"; + print '
'; + } + + print "
\n"; + print ''; + + + $sql = "SELECT p.ref,cfd.fk_product, cfd.qty"; + $sql.= ", cfd.rowid"; + $sql.= ", p.label, e.label as entrepot"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd"; + $sql.= " , ".MAIN_DB_PREFIX."product as p "; + $sql.= " , ".MAIN_DB_PREFIX."entrepot as e "; + $sql.= " WHERE cfd.fk_commande = ".$commande->id; + $sql.= " AND cfd.fk_product = p.rowid"; + $sql.= " AND cfd.fk_entrepot = e.rowid"; + $sql.= " ORDER BY cfd.rowid ASC;"; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + + if ($num) + { + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + $var=false; + + while ($i < $num) + { + $objp = $db->fetch_object($resql); + print ""; + print '\n"; + + print ''; + print ''; + print "\n"; + + $i++; + $var=!$var; + } + $db->free($resql); + } + else + { + dolibarr_print_error($db); + } + + print "
'.$langs->trans("Description").''.$langs->trans("QtyDispatched").''.$langs->trans("Warehouse").'
'; + print ''.img_object($langs->trans("ShowProduct"),'product').' '.$objp->ref.''; + print ' - '.$objp->label; + print "'.$objp->qty.''.stripslashes($objp->entrepot).'
\n"; + print ''; + + /** + * Boutons actions + */ + if ($user->societe_id == 0 && $commande->statut < 3 && ($_GET["action"] <> 'valid' || $_GET['action'] == 'builddoc')) + { + print '
'; + + if ($commande->statut == 0 && $num > 0) + { + if ($user->rights->fournisseur->commande->valider) + { + print ''.$langs->trans("Valid").''; + } + } + + if ($commande->statut == 1) + { + if ($user->rights->fournisseur->commande->approuver) + { + print ''.$langs->trans("ApproveOrder").''; + + print ''.$langs->trans("RefuseOrder").''; + } + + if ($user->rights->fournisseur->commande->annuler) + { + print ''.$langs->trans("CancelOrder").''; + } + + } + + if ($commande->statut == 2) + { + if ($user->rights->fournisseur->commande->annuler) + { + print ''.$langs->trans("CancelOrder").''; + } + } + + if ($commande->statut == 0) + { + if ($user->rights->fournisseur->commande->creer) + { + print ''.$langs->trans("Delete").''; + } + } + print "
"; + } + /* + * + * + */ } - - // Auteur - print ''.$langs->trans("AuthorRequest").''; - print ''.$author->getNomUrl(1).''; - print ''; - print " "; - print ""; - - if ($mesg) print $mesg; - else print '
'; - - /* - * Lignes de commandes - */ - if ($commande->statut == 3 || $commande->statut == 4 || $commande->statut == 5) + else { - print '
'; - print ''; - print ''; - - $sql = "SELECT cfd.fk_product, sum(cfd.qty) as qty"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd"; - $sql.= " WHERE cfd.fk_commande = ".$commande->id; - $sql.= " GROUP BY cfd.fk_product"; - - $resql = $db->query($sql); - if ($resql) - { - while ( $row = $db->fetch_row($resql) ) - { - $products_dispatched[$row[0]] = $row[1]; - } - $db->free($resql); - } - - $sql = "SELECT l.ref,l.fk_product,l.description, l.subprice, sum(l.qty) as qty"; - $sql.= ", l.rowid"; - $sql.= ", p.label"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON l.fk_product=p.rowid"; - $sql.= " WHERE l.fk_commande = ".$commande->id; - $sql.= " GROUP BY l.fk_product"; - $sql.= " ORDER BY l.rowid"; - - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - - if ($num) - { - print ''; - print ''; - - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - - $entrepot = new Entrepot($db); - - $var=true; - while ($i < $num) - { - $objp = $db->fetch_object($resql); - // On n'affiche pas les produits personnalisés - if ($objp->fk_product) - { - $var=!$var; - print ""; - print '\n"; - - print ''; - print ''; - - print '\n"; - print ''; - print "\n"; - } - $i++; - } - $db->free($resql); - } - else - { - dolibarr_print_error($db); - } - - print "
'.$langs->trans("Description").''.$langs->trans("QtyOrdered").''.$langs->trans("QtyDispatched").''.$langs->trans("Warehouse").''.$langs->trans("QtyDelivered").'
'; - print ''.img_object($langs->trans("ShowProduct"),'product').' '.$objp->ref.''; - print ' - '.$objp->label; - if ($objp->description) print '
'.nl2br($objp->description); - print ''; - print ''; - print "
'.$objp->qty.''.$products_dispatched[$objp->fk_product].''; - - if (sizeof($user->entrepots) === 1) - { - $uentrepot = array(); - $uentrepot[$user->entrepots[0]['id']] = $user->entrepots[0]['label']; - $html->select_array("entrepot_".$i, $uentrepot); - } - else - { - $html->select_array("entrepot_".$i, $entrepot->list_array()); - } - print "
\n"; - print "
\n"; - print '
'; + // Commande non trouvée + dolibarr_print_error($db); } - - print "
\n"; - print ''; - - - $sql = "SELECT p.ref,cfd.fk_product, cfd.qty"; - $sql.= ", cfd.rowid"; - $sql.= ", p.label, e.label as entrepot"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as cfd"; - $sql.= " , ".MAIN_DB_PREFIX."product as p "; - $sql.= " , ".MAIN_DB_PREFIX."entrepot as e "; - $sql.= " WHERE cfd.fk_commande = ".$commande->id; - $sql.= " AND cfd.fk_product = p.rowid"; - $sql.= " AND cfd.fk_entrepot = e.rowid"; - $sql.= " ORDER BY cfd.rowid ASC;"; - - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - - if ($num) - { - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - $var=false; - - while ($i < $num) - { - $objp = $db->fetch_object($resql); - print ""; - print '\n"; - - print ''; - print ''; - print "\n"; - - $i++; - $var=!$var; - } - $db->free($resql); - } - else - { - dolibarr_print_error($db); - } - - print "
'.$langs->trans("Description").''.$langs->trans("QtyDispatched").''.$langs->trans("Warehouse").'
'; - print ''.img_object($langs->trans("ShowProduct"),'product').' '.$objp->ref.''; - print ' - '.$objp->label; - print "'.$objp->qty.''.stripslashes($objp->entrepot).'
\n"; - print ''; - - /** - * Boutons actions - */ - if ($user->societe_id == 0 && $commande->statut < 3 && ($_GET["action"] <> 'valid' || $_GET['action'] == 'builddoc')) - { - print '
'; - - if ($commande->statut == 0 && $num > 0) - { - if ($user->rights->fournisseur->commande->valider) - { - print ''.$langs->trans("Valid").''; - } - } - - if ($commande->statut == 1) - { - if ($user->rights->fournisseur->commande->approuver) - { - print ''.$langs->trans("ApproveOrder").''; - - print ''.$langs->trans("RefuseOrder").''; - } - - if ($user->rights->fournisseur->commande->annuler) - { - print ''.$langs->trans("CancelOrder").''; - } - - } - - if ($commande->statut == 2) - { - if ($user->rights->fournisseur->commande->annuler) - { - print ''.$langs->trans("CancelOrder").''; - } - } - - if ($commande->statut == 0) - { - if ($user->rights->fournisseur->commande->creer) - { - print ''.$langs->trans("Delete").''; - } - } - print "
"; - } - /* - * - * - */ - } - else - { - // Commande non trouvée - dolibarr_print_error($db); - } } $db->close(); diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 15057b52ca0..8002c21c1f0 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -28,6 +28,7 @@ require('./pre.inc.php'); require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); +require_once(DOL_DOCUMENT_ROOT."/html.formorder.class.php"); require_once(DOL_DOCUMENT_ROOT.'/includes/modules/supplier_order/modules_commandefournisseur.php'); require_once DOL_DOCUMENT_ROOT."/fourn/fournisseur.product.class.php"; if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/project.class.php'); @@ -464,6 +465,7 @@ llxHeader('',$langs->trans("OrderCard"),"CommandeFournisseur"); $html = new Form($db); $formfile = new FormFile($db); +$formorder = new FormOrder($db); /* *************************************************************************** */ /* */ @@ -1015,7 +1017,7 @@ if ($id > 0) print ''; print ''.$langs->trans("OrderMode").''; - $html->select_methodes_commande('',"methodecommande",1); + $formorder->select_methodes_commande('',"methodecommande",1); print ''; print ''.$langs->trans("Comment").''; diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 630a458f1ab..66393537303 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -170,207 +170,6 @@ class Form } - /** - * \brief Retourne la liste déroulante des départements/province/cantons tout pays confondu ou pour un pays donné. - * \remarks Dans le cas d'une liste tout pays confondus, l'affichage fait une rupture sur le pays. - * \remarks La cle de la liste est le code (il peut y avoir plusieurs entrée pour - * un code donnée mais dans ce cas, le champ pays diffère). - * Ainsi les liens avec les départements se font sur un département indépendemment de son nom. - * \param selected code forme juridique a présélectionné - * \param pays_code 0=liste tous pays confondus, sinon code du pays à afficher - */ - function select_departement($selected='',$pays_code=0) - { - global $conf,$langs,$user; - - dolibarr_syslog("Form::select_departement selected=$selected, pays_code=$pays_code",LOG_DEBUG); - - $langs->load("dict"); - - $htmlname='departement_id'; - - // On recherche les départements/cantons/province active d'une region et pays actif - $sql = "SELECT d.rowid, d.code_departement as code , d.nom, d.active, p.libelle as libelle_pays, p.code as code_pays FROM"; - $sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_pays as p"; - $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=p.rowid"; - $sql .= " AND d.active = 1 AND r.active = 1 AND p.active = 1"; - if ($pays_code) $sql .= " AND p.code = '".$pays_code."'"; - $sql .= " ORDER BY p.code, d.code_departement"; - - dolibarr_syslog("Form::select_departement sql=".$sql); - $result=$this->db->query($sql); - if ($result) - { - print ''; - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - } - else { - dolibarr_print_error($this->db); - } - } - - - /** - * \brief Retourne la liste déroulante des regions actives dont le pays est actif - * \remarks La cle de la liste est le code (il peut y avoir plusieurs entrée pour - * un code donnée mais dans ce cas, le champ pays et lang diffère). - * Ainsi les liens avec les regions se font sur une region independemment - * de son nom. - */ - - function select_region($selected='',$htmlname='region_id') - { - global $conf,$langs; - $langs->load("dict"); - - $sql = "SELECT r.rowid, r.code_region as code, r.nom as libelle, r.active, p.libelle as libelle_pays FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_pays as p"; - $sql .= " WHERE r.fk_pays=p.rowid AND r.active = 1 and p.active = 1 ORDER BY libelle_pays, libelle ASC"; - - dolibarr_syslog("Form::select_region sql=".$sql); - if ($this->db->query($sql)) - { - print ''; - } - else { - dolibarr_print_error($this->db); - } - } - - - /** - * \brief Renvoie la liste des sources de commandes - * \param selected Id de la source pré-sélectionnée - * \param htmlname Nom de la liste deroulante - * \param addempty 0=liste sans valeur nulle, 1=ajoute valeur inconnue - * \return array Tableau des sources de commandes - */ - function selectSourcesCommande($selected='',$htmlname='source_id',$addempty=0) - { - global $conf,$langs; - print ''; - } - - - /** - * - * - */ - function select_methodes_commande($selected='',$htmlname='source_id',$addempty=0) - { - global $conf,$langs; - $listemethodes=array(); - - $sql = "SELECT rowid, libelle "; - $sql.= " FROM ".MAIN_DB_PREFIX."c_methode_commande_fournisseur"; - $sql.= " WHERE active = 1"; - - dolibarr_syslog("Form::select_methodes_commande sql=".$sql); - $resql=$this->db->query($sql); - if ($resql) - { - $i = 0; - $num = $this->db->num_rows($resql); - while ($i < $num) - { - $obj = $this->db->fetch_object($resql); - $listemethodes[$obj->rowid] = $obj->libelle; - $i++; - } - } - else - { - dolibarr_print_error($this->db); - return -1; - } - - print $this->select_array($htmlname,$listemethodes,$selected,$addempty); - return 1; - } /** * \brief Retourne la liste déroulante des pays actifs, dans la langue de l'utilisateur @@ -515,27 +314,6 @@ class Form } - /** - * \brief Retourne la liste des types de comptes financiers - * \param selected Type pré-sélectionné - * \param htmlname Nom champ formulaire - */ - function select_type_actions($selected='',$htmlname='actioncode') - { - global $langs,$user; - - require_once(DOL_DOCUMENT_ROOT."/cactioncomm.class.php"); - $caction=new CActionComm($this->db); - - $arraylist=$caction->liste_array(1,'code'); - $arraylist[0]=' '; - asort($arraylist); - - $this->select_array($htmlname, $arraylist, $selected); - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - } - - /** * \brief Return list of social contributions * \param selected Preselected type @@ -1361,110 +1139,6 @@ class Form } - /** - * \brief Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre) - * \param mode 0=renvoi id+libelle, 1=renvoi code+libelle - * \return array tableau des types d'effectifs - */ - function effectif_array($mode=0) - { - $effs = array(); - - $sql = "SELECT id, code, libelle"; - $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif"; - $sql.= " WHERE active = 1"; - $sql .= " ORDER BY id ASC"; - dolibarr_syslog('Form::effectif_array sql='.$sql,LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - - while ($i < $num) - { - $objp = $this->db->fetch_object($resql); - if (! $mode) $key=$objp->id; - else $key=$objp->code; - - $effs[$key] = $objp->libelle!='-'?$objp->libelle:''; - $i++; - } - $this->db->free($resql); - } - return $effs; - } - - /** - * \brief Renvoie la liste des formes juridiques existantes (pas de traduction car unique au pays) - * \return array tableau des formes juridiques - */ - function forme_juridique_array() - { - $fj = array(); - - $sql = "SELECT code, libelle"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_forme_juridique"; - $sql.= " WHERE active = 1"; - $sql.= " ORDER BY code ASC"; - dolibarr_syslog('Form::forme_juridique_array sql='.$sql,LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - - while ($i < $num) - { - $objp = $this->db->fetch_object($resql); - $fj[$objp->code] = $objp->libelle!='-'?$objp->libelle:''; - $i++; - } - $this->db->free($resql); - } - return $fj; - } - - /** - * \brief Renvoie la liste des libelles traduits des types actifs de societes - * \param mode 0=renvoi id+libelle, 1=renvoi code+libelle - * \return array tableau des types - */ - function typent_array($mode=0) - { - global $langs; - - $effs = array(); - - $sql = "SELECT id, code, libelle"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_typent"; - $sql.= " WHERE active = 1"; - $sql.= " ORDER by id"; - dolibarr_syslog('Form::typent_array sql='.$sql,LOG_DEBUG); - $resql=$this->db->query($sql); - if ($resql) - { - $num = $this->db->num_rows($resql); - $i = 0; - - while ($i < $num) - { - $objp = $this->db->fetch_object($resql); - if (! $mode) $key=$objp->id; - else $key=$objp->code; - - if ($langs->trans($objp->code) != $objp->code) - $effs[$key] = $langs->trans($objp->code); - else - $effs[$key] = $objp->libelle!='-'?$objp->libelle:''; - $i++; - } - $this->db->free($resql); - } - - return $effs; - } - /** * \brief Charge dans cache la liste des conditions de paiements possibles * \return int Nb lignes chargées, 0 si déjà chargées, <0 si ko @@ -1791,128 +1465,6 @@ class Form } - - /** - * \brief Retourne la liste déroulante des civilite actives - * \param selected civilite pré-sélectionnée - */ - function select_civilite($selected='') - { - global $conf,$langs,$user; - $langs->load("dict"); - - $sql = "SELECT rowid, code, civilite, active FROM ".MAIN_DB_PREFIX."c_civilite"; - $sql .= " WHERE active = 1"; - - dolibarr_syslog("Form::select_civilite sql=".$sql); - if ($this->db->query($sql)) - { - print ''; - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - } - else - { - dolibarr_print_error($this->db); - } - } - - - /** - * \brief Retourne la liste déroulante des formes juridiques tous pays confondus ou pour un pays donné. - * \remarks Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays - * \param selected Code forme juridique a pré-sélectionné - * \param pays_code 0=liste tous pays confondus, sinon code du pays à afficher - */ - function select_forme_juridique($selected='',$pays_code=0) - { - global $conf,$langs,$user; - $langs->load("dict"); - - // On recherche les formes juridiques actives des pays actifs - $sql = "SELECT f.rowid, f.code as code , f.libelle as nom, f.active, p.libelle as libelle_pays, p.code as code_pays"; - $sql .= " FROM llx_c_forme_juridique as f, llx_c_pays as p"; - $sql .= " WHERE f.fk_pays=p.rowid"; - $sql .= " AND f.active = 1 AND p.active = 1"; - if ($pays_code) $sql .= " AND p.code = '".$pays_code."'"; - $sql .= " ORDER BY p.code, f.code"; - - dolibarr_syslog("Form::select_forme_juridique sql=".$sql); - $result=$this->db->query($sql); - if ($result) - { - print '
'; - print ''; - if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); - print '
'; - } - else - { - dolibarr_print_error($this->db); - } - } - - /** * \brief Affiche formulaire de demande de confirmation * \param page page @@ -2082,38 +1634,6 @@ class Form } } - /** - * \brief Affiche formulaire de selection de l'assujétissement à la TVA - * \param page Page - * \param selected Id condition pré-sélectionnée - * \param htmlname Nom du formulaire select - */ - function form_assujetti_tva($page, $selected='', $htmlname='') - { - global $langs; - $options = array(0=>"non",1=>"oui"); - if ($htmlname != "none") - { - print '
'; - print ''; - print ''; - print ''; - print ''; - print '
'; - $this->select_assujetti_tva($selected,$htmlname); - print '
'; - } - else - { - if ($selected != "") - { - print $options[$selected]; - } else { - print " "; - } - } - } - /** * \brief Affiche formulaire de selection des modes de reglement @@ -2148,58 +1668,6 @@ class Form } - /** - * \brief Affiche formulaire de selection des modes de reglement - * \param page Page - * \param selected Id or code preselected - * \param htmlname Nom du formulaire select - * \param empty Add empty value in list - */ - function form_prospect_level($page, $selected='', $htmlname='prospect_level_id', $empty=0) - { - global $langs; - - print '
'; - print ''; - print ''; - print ''; - print ''; - print '
'; - - print ''; - - print '
'; - } - /** * \brief Affiche formulaire de selection de la remise fixe * \param page Page URL where form is shown diff --git a/htdocs/html.formactions.class.php b/htdocs/html.formactions.class.php index 09c7de801df..16457a369dd 100644 --- a/htdocs/html.formactions.class.php +++ b/htdocs/html.formactions.class.php @@ -148,4 +148,27 @@ class FormActions } } + + /** + * \brief Retourne la liste des types de comptes financiers + * \param selected Type pré-sélectionné + * \param htmlname Nom champ formulaire + */ + function select_type_actions($selected='',$htmlname='actioncode') + { + global $langs,$user; + + require_once(DOL_DOCUMENT_ROOT."/cactioncomm.class.php"); + require_once(DOL_DOCUMENT_ROOT."/html.form.class.php"); + $caction=new CActionComm($this->db); + $form=new Form($this->db); + + $arraylist=$caction->liste_array(1,'code'); + $arraylist[0]=' '; + asort($arraylist); + + $form->select_array($htmlname, $arraylist, $selected); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + } + } diff --git a/htdocs/html.formcompany.class.php b/htdocs/html.formcompany.class.php new file mode 100644 index 00000000000..94600a9c226 --- /dev/null +++ b/htdocs/html.formcompany.class.php @@ -0,0 +1,441 @@ + + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (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 + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file htdocs/html.formcompany.class.php + * \brief Fichier de la classe des fonctions prédéfinie de composants html + * \version $Id$ + */ + + +/** + * \class FormCompany + * \brief Classe permettant la génération de composants html + * \remarks Only common components must be here. + */ +class FormCompany +{ + var $db; + var $error; + + + + /** + * \brief Constructeur + * \param DB handler d'accès base de donnée + */ + function FormCompany($DB) + { + $this->db = $DB; + + return 1; + } + + + /** + * \brief Renvoie la liste des libelles traduits des types actifs de societes + * \param mode 0=renvoi id+libelle, 1=renvoi code+libelle + * \return array tableau des types + */ + function typent_array($mode=0) + { + global $langs; + + $effs = array(); + + $sql = "SELECT id, code, libelle"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_typent"; + $sql.= " WHERE active = 1"; + $sql.= " ORDER by id"; + dolibarr_syslog('Form::typent_array sql='.$sql,LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + + while ($i < $num) + { + $objp = $this->db->fetch_object($resql); + if (! $mode) $key=$objp->id; + else $key=$objp->code; + + if ($langs->trans($objp->code) != $objp->code) + $effs[$key] = $langs->trans($objp->code); + else + $effs[$key] = $objp->libelle!='-'?$objp->libelle:''; + $i++; + } + $this->db->free($resql); + } + + return $effs; + } + + /** + * \brief Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre) + * \param mode 0=renvoi id+libelle, 1=renvoi code+libelle + * \return array tableau des types d'effectifs + */ + function effectif_array($mode=0) + { + $effs = array(); + + $sql = "SELECT id, code, libelle"; + $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif"; + $sql.= " WHERE active = 1"; + $sql .= " ORDER BY id ASC"; + dolibarr_syslog('Form::effectif_array sql='.$sql,LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $num = $this->db->num_rows($resql); + $i = 0; + + while ($i < $num) + { + $objp = $this->db->fetch_object($resql); + if (! $mode) $key=$objp->id; + else $key=$objp->code; + + $effs[$key] = $objp->libelle!='-'?$objp->libelle:''; + $i++; + } + $this->db->free($resql); + } + return $effs; + } + + + /** + * \brief Affiche formulaire de selection des modes de reglement + * \param page Page + * \param selected Id or code preselected + * \param htmlname Nom du formulaire select + * \param empty Add empty value in list + */ + function form_prospect_level($page, $selected='', $htmlname='prospect_level_id', $empty=0) + { + global $langs; + + print '
'; + print ''; + print ''; + print ''; + print ''; + print '
'; + + print ''; + + print '
'; + } + + + /** + * \brief Retourne la liste déroulante des départements/province/cantons tout pays confondu ou pour un pays donné. + * \remarks Dans le cas d'une liste tout pays confondus, l'affichage fait une rupture sur le pays. + * \remarks La cle de la liste est le code (il peut y avoir plusieurs entrée pour + * un code donnée mais dans ce cas, le champ pays diffère). + * Ainsi les liens avec les départements se font sur un département indépendemment de son nom. + * \param selected code forme juridique a présélectionné + * \param pays_code 0=liste tous pays confondus, sinon code du pays à afficher + */ + function select_departement($selected='',$pays_code=0) + { + global $conf,$langs,$user; + + dolibarr_syslog("Form::select_departement selected=$selected, pays_code=$pays_code",LOG_DEBUG); + + $langs->load("dict"); + + $htmlname='departement_id'; + + // On recherche les départements/cantons/province active d'une region et pays actif + $sql = "SELECT d.rowid, d.code_departement as code , d.nom, d.active, p.libelle as libelle_pays, p.code as code_pays FROM"; + $sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_pays as p"; + $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=p.rowid"; + $sql .= " AND d.active = 1 AND r.active = 1 AND p.active = 1"; + if ($pays_code) $sql .= " AND p.code = '".$pays_code."'"; + $sql .= " ORDER BY p.code, d.code_departement"; + + dolibarr_syslog("Form::select_departement sql=".$sql); + $result=$this->db->query($sql); + if ($result) + { + print ''; + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + } + else + { + dolibarr_print_error($this->db); + } + } + + + /** + * \brief Retourne la liste déroulante des regions actives dont le pays est actif + * \remarks La cle de la liste est le code (il peut y avoir plusieurs entrée pour + * un code donnée mais dans ce cas, le champ pays et lang diffère). + * Ainsi les liens avec les regions se font sur une region independemment + * de son nom. + */ + function select_region($selected='',$htmlname='region_id') + { + global $conf,$langs; + $langs->load("dict"); + + $sql = "SELECT r.rowid, r.code_region as code, r.nom as libelle, r.active, p.libelle as libelle_pays FROM ".MAIN_DB_PREFIX."c_regions as r, ".MAIN_DB_PREFIX."c_pays as p"; + $sql .= " WHERE r.fk_pays=p.rowid AND r.active = 1 and p.active = 1 ORDER BY libelle_pays, libelle ASC"; + + dolibarr_syslog("Form::select_region sql=".$sql); + if ($this->db->query($sql)) + { + print ''; + } + else + { + dolibarr_print_error($this->db); + } + } + + + /** + * \brief Retourne la liste déroulante des civilite actives + * \param selected civilite pré-sélectionnée + */ + function select_civilite($selected='') + { + global $conf,$langs,$user; + $langs->load("dict"); + + $sql = "SELECT rowid, code, civilite, active FROM ".MAIN_DB_PREFIX."c_civilite"; + $sql .= " WHERE active = 1"; + + dolibarr_syslog("Form::select_civilite sql=".$sql); + if ($this->db->query($sql)) + { + print ''; + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + } + else + { + dolibarr_print_error($this->db); + } + } + + + /** + * \brief Retourne la liste déroulante des formes juridiques tous pays confondus ou pour un pays donné. + * \remarks Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays + * \param selected Code forme juridique a pré-sélectionné + * \param pays_code 0=liste tous pays confondus, sinon code du pays à afficher + */ + function select_forme_juridique($selected='',$pays_code=0) + { + global $conf,$langs,$user; + $langs->load("dict"); + + // On recherche les formes juridiques actives des pays actifs + $sql = "SELECT f.rowid, f.code as code , f.libelle as nom, f.active, p.libelle as libelle_pays, p.code as code_pays"; + $sql .= " FROM llx_c_forme_juridique as f, llx_c_pays as p"; + $sql .= " WHERE f.fk_pays=p.rowid"; + $sql .= " AND f.active = 1 AND p.active = 1"; + if ($pays_code) $sql .= " AND p.code = '".$pays_code."'"; + $sql .= " ORDER BY p.code, f.code"; + + dolibarr_syslog("Form::select_forme_juridique sql=".$sql); + $result=$this->db->query($sql); + if ($result) + { + print '
'; + print ''; + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); + print '
'; + } + else + { + dolibarr_print_error($this->db); + } + } + +} + +?> diff --git a/htdocs/html.formorder.class.php b/htdocs/html.formorder.class.php new file mode 100644 index 00000000000..c8ce07f0a0f --- /dev/null +++ b/htdocs/html.formorder.class.php @@ -0,0 +1,114 @@ + + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (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 + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + * \file htdocs/html.formorder.class.php + * \brief Fichier de la classe des fonctions prédéfinie de composants html + * \version $Id$ + */ + + +/** + * \class FormOrder + * \brief Classe permettant la génération de composants html + * \remarks Only common components must be here. + */ +class FormOrder +{ + var $db; + var $error; + + + + /** + * \brief Constructeur + * \param DB handler d'accès base de donnée + */ + function FormOrder($DB) + { + $this->db = $DB; + + return 1; + } + + + /** + * \brief Renvoie la liste des sources de commandes + * \param selected Id de la source pré-sélectionnée + * \param htmlname Nom de la liste deroulante + * \param addempty 0=liste sans valeur nulle, 1=ajoute valeur inconnue + * \return array Tableau des sources de commandes + */ + function selectSourcesCommande($selected='',$htmlname='source_id',$addempty=0) + { + global $conf,$langs; + print ''; + } + + + /** + * + * + */ + function select_methodes_commande($selected='',$htmlname='source_id',$addempty=0) + { + global $conf,$langs; + $listemethodes=array(); + + $sql = "SELECT rowid, libelle "; + $sql.= " FROM ".MAIN_DB_PREFIX."c_methode_commande_fournisseur"; + $sql.= " WHERE active = 1"; + + dolibarr_syslog("Form::select_methodes_commande sql=".$sql); + $resql=$this->db->query($sql); + if ($resql) + { + $i = 0; + $num = $this->db->num_rows($resql); + while ($i < $num) + { + $obj = $this->db->fetch_object($resql); + $listemethodes[$obj->rowid] = $obj->libelle; + $i++; + } + } + else + { + dolibarr_print_error($this->db); + return -1; + } + + print $this->select_array($htmlname,$listemethodes,$selected,$addempty); + return 1; + } + +} + +?> diff --git a/htdocs/soc.php b/htdocs/soc.php index 7b4024f3632..5a53fd81d6c 100644 --- a/htdocs/soc.php +++ b/htdocs/soc.php @@ -30,6 +30,7 @@ require("pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/html.formcompany.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); $langs->load("companies"); @@ -266,6 +267,8 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' && llxHeader(); $form = new Form($db); +$formcompany = new FormCompany($db); + $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; @@ -390,7 +393,7 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create') print ' '; print ''.$langs->trans("UserTitle").''; - print $form->select_civilite($contact->civilite_id).''; + print $formcompany->select_civilite($contact->civilite_id).''; print ' '; } @@ -483,7 +486,7 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create') print ''.$langs->trans('State').''; if ($soc->pays_id) { - $form->select_departement($soc->departement_id,$soc->pays_code); + $formcompany->select_departement($soc->departement_id,$soc->pays_code); } else { @@ -546,7 +549,7 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create') print ''; if ($soc->pays_id) { - $form->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); + $formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); } else { @@ -555,11 +558,11 @@ $_GET["action"] == 'create' || $_POST["action"] == 'create') print ''; print ''.$langs->trans("Type").''."\n"; - $form->select_array("typent_id",$form->typent_array(0), $soc->typent_id); + $form->select_array("typent_id",$formcompany->typent_array(0), $soc->typent_id); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print ''; print ''.$langs->trans("Staff").''; - $form->select_array("effectif_id",$form->effectif_array(0), $soc->effectif_id); + $form->select_array("effectif_id",$formcompany->effectif_array(0), $soc->effectif_id); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print ''; @@ -834,7 +837,7 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') print ''; print ''.$langs->trans('State').''; - $form->select_departement($soc->departement_id,$soc->pays_code); + $formcompany->select_departement($soc->departement_id,$soc->pays_code); print ''; print ''.$langs->trans('Phone').''; @@ -920,15 +923,15 @@ elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit') print ''.$langs->trans("Capital").' '.$langs->trans("Currency".$conf->monnaie).''; print ''.$langs->trans('JuridicalStatus').''; - $form->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); + $formcompany->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code); print ''; print ''.$langs->trans("Type").''; - $form->select_array("typent_id",$form->typent_array(0), $soc->typent_id); + $form->select_array("typent_id",$formcompany->typent_array(0), $soc->typent_id); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print ''; print ''.$langs->trans("Staff").''; - $form->select_array("effectif_id",$form->effectif_array(0), $soc->effectif_id); + $form->select_array("effectif_id",$formcompany->effectif_array(0), $soc->effectif_id); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print ''; @@ -1147,7 +1150,7 @@ else print ''.$langs->trans('JuridicalStatus').''.$soc->forme_juridique.''; // Type + Staff - $arr = $form->typent_array(1); + $arr = $formcompany->typent_array(1); $soc->typent= $arr[$soc->typent_code]; print ''.$langs->trans("Type").''.$soc->typent.''.$langs->trans("Staff").''.$soc->effectif.'';