--- dolibarr/htdocs/soc.php 2008-07-28 05:00:14.000000000 +0200 +++ new_dolibarr/htdocs/soc.php 2008-07-30 16:15:44.000000000 +0200 @@ -30,6 +30,7 @@ require("pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); +require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php"); $langs->load("companies"); $langs->load("commercial"); @@ -177,7 +178,13 @@ if ($result >= 0) { $db->commit(); - + $ajoutCat=$_POST["catMere"]; + $ajoutCatFournisseur=$_POST["catMereFournisseur"]; + $cat = new Categorie($db); + $cat->add_cat_societe($ajoutCat,"societe"); + $cat->add_cat_societe($ajoutCatFournisseur,"fournisseur"); + + if ( $soc->client == 1 ) { Header("Location: comm/fiche.php?socid=".$soc->id); @@ -392,11 +399,15 @@ } // Client / Prospect - print ''.$langs->trans('ProspectCustomer').''; + print ''; print ''; print ''; - print ''; + print ''; + print $form->select_all_categories(2).''; + print ''.$langs->trans('CustomerCode').''; print ''; - print ''; print ''; print '
'; @@ -418,8 +429,9 @@ // Fournisseur print '
'.$langs->trans('Supplier').''; + print ''.$langs->trans('Supplier').'categorie'; print $form->selectyesno("fournisseur",$soc->fournisseur,1); + print '
'.$form->select_all_categories(1,0,"catMereFournisseur").'
'.$langs->trans('SupplierCode').''; print '
'; --- dolibarr/htdocs/categories/categorie.class.php 2008-07-02 05:00:13.000000000 +0200 +++ new_dolibarr/htdocs/categories/categorie.class.php 2008-07-30 16:15:39.000000000 +0200 @@ -980,5 +980,21 @@ return -1; } } +function add_cat_societe($nocategorie,$type) +{ + $sql = "SELECT max(rowid) FROM ".MAIN_DB_PREFIX."societe"; + $res = $this->db->query ($sql); + if ($res) + { + while ($cat = $this->db->fetch_array ($res)) + { + $noSociete= $cat['max(rowid)']; + } + } + $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".$type; + $sql.= " VALUES ($nocategorie,$noSociete)"; + $this->db->query($sql); +} } + ?>