From c78bd22adc0aedc7d2d379dbd09eaaf96bf097d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 18 Feb 2009 12:26:55 +0000 Subject: [PATCH] Uniformize code for contacts linking --- htdocs/comm/propal/contact.php | 22 ++-- htdocs/commande/contact.php | 18 +-- htdocs/commonobject.class.php | 101 ---------------- htdocs/compta/facture/contact.php | 32 ++--- htdocs/contrat/contact.php | 24 ++-- htdocs/fichinter/contact.php | 31 ++--- htdocs/fourn/commande/contact.php | 14 +-- htdocs/fourn/commande/fiche.php | 22 ++-- htdocs/fourn/facture/contact.php | 14 +-- htdocs/fourn/fiche.php | 186 +++++++++++++++--------------- htdocs/html.formcompany.class.php | 115 +++++++++++++++++- 11 files changed, 297 insertions(+), 282 deletions(-) diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index f72b13f7401..e690c8651ba 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -28,6 +28,7 @@ require ("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/propal.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/propal.lib.php"); +require_once(DOL_DOCUMENT_ROOT.'/html.formcompany.class.php'); $langs->load("facture"); $langs->load("orders"); @@ -143,9 +144,14 @@ if ($_GET["action"] == 'deleteline' && $user->rights->propale->creer) } +/* + * View + */ + llxHeader('', $langs->trans("Proposal"), "Propal"); $html = new Form($db); +$formcompany= new FormCompany($db); $contactstatic=new Contact($db); @@ -208,7 +214,7 @@ if ($id > 0) /* * Ajouter une ligne de contact - * Non affiché en mode modification de ligne + * Non affich� en mode modification de ligne */ if ($_GET["action"] != 'editline' && $user->rights->propale->creer) { @@ -239,12 +245,12 @@ if ($id > 0) print ''; print ''; - // On récupère les id des users déjà sélectionnés + // On r�cup�re les id des users d�j� s�lectionn�s //$userAlreadySelected = $propal->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type $html->select_users($user->id,'contactid',0,$userAlreadySelected); print ''; print ''; - $propal->selectTypeContact($propal, '', 'type','internal'); + $formcompany->selectTypeContact($propal, '', 'type','internal'); print ''; print ''; print ''; @@ -266,17 +272,16 @@ if ($id > 0) print ''; $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$propal->client->id; - $selectedCompany = $propal->selectCompaniesForNewContact($propal, 'propalid', $selectedCompany, $htmlname = 'newcompany'); + $selectedCompany = $formcompany->selectCompaniesForNewContact($propal, 'propalid', $selectedCompany, $htmlname = 'newcompany'); print ''; print ''; - // On récupère les id des contacts déjà sélectionnés //$contactAlreadySelected = $propal->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type $nbofcontacts=$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print ''; - $propal->selectTypeContact($propal, '', 'type','external'); + $formcompany->selectTypeContact($propal, '', 'type','external'); print ''; print ' 0) print ' '; } - // Liste des contacts liés + // Liste des contacts li�s print ''; print ''.$langs->trans("Source").''; print ''.$langs->trans("Company").''; @@ -382,8 +387,7 @@ if ($id > 0) } else { - // Propale non trouvée - print "Propale inexistante ou accès refusé"; + print "ErrorRecordNotFound"; } } diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index ac8caa4b0ee..7ae753948a8 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -1,6 +1,6 @@ - * Copyright (C) 2005-2007 Destailleur Laurent + * Copyright (C) 2005-2009 Destailleur Laurent * * 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 @@ -28,6 +28,7 @@ require ("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/commande/commande.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/order.lib.php"); +require_once(DOL_DOCUMENT_ROOT.'/html.formcompany.class.php'); $langs->load("facture"); $langs->load("orders"); @@ -146,6 +147,7 @@ if ($_GET["action"] == 'deleteline' && $user->rights->commande->creer) llxHeader('', $langs->trans("Order"), "Commande"); $html = new Form($db); +$formcompany = new FormCompany($db); $contactstatic=new Contact($db); @@ -210,7 +212,7 @@ if ($id > 0 || ! empty($ref)) /* * Ajouter une ligne de contact - * Non affiché en mode modification de ligne + * Non affich� en mode modification de ligne */ if ($_GET["action"] != 'editline' && $user->rights->facture->creer) { @@ -241,12 +243,11 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - // On récupère les id des users déjà sélectionnés //$userAlreadySelected = $commande->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type $html->select_users($user->id,'contactid',0,$userAlreadySelected); print ''; print ''; - $commande->selectTypeContact($commande, '', 'type','internal'); + $formcompany->selectTypeContact($commande, '', 'type','internal'); print ''; print ''; print ''; @@ -268,17 +269,16 @@ if ($id > 0 || ! empty($ref)) print ''; $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$commande->client->id; - $selectedCompany = $commande->selectCompaniesForNewContact($commande, 'id', $selectedCompany, $htmlname = 'newcompany'); + $selectedCompany = $formcompany->selectCompaniesForNewContact($commande, 'id', $selectedCompany, 'newcompany'); print ''; print ''; - // On récupère les id des contacts déjà sélectionnés // $contactAlreadySelected = $commande->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type $nbofcontacts=$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print ''; - $commande->selectTypeContact($commande, '', 'type','external'); + $formcompany->selectTypeContact($commande, '', 'type','external'); print ''; print ' 0 || ! empty($ref)) print ' '; } - // Liste des contacts liés + // List of linked contacts print ''; print ''.$langs->trans("Source").''; print ''.$langs->trans("Company").''; @@ -385,7 +385,7 @@ if ($id > 0 || ! empty($ref)) else { // Contrat non trouv - print "Contrat inexistant ou accés refusé"; + print "ErrorRecordNotFound"; } } diff --git a/htdocs/commonobject.class.php b/htdocs/commonobject.class.php index 920644bbdd9..aad56a340a4 100644 --- a/htdocs/commonobject.class.php +++ b/htdocs/commonobject.class.php @@ -395,107 +395,6 @@ class CommonObject return $result; } -/** - * \brief Retourne la liste d�roulante des soci�t�s - * \param object Fetch du document - * \param var_id Nom de la variable de l'id du document - * \param selected Societe pr�s�lectionn�e - * \param htmlname Nom champ formulaire - */ - function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany') - { - global $conf, $langs; - - // On recherche les societes - $sql = "SELECT s.rowid, s.nom FROM"; - $sql .= " ".MAIN_DB_PREFIX."societe as s"; - if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT) - { - $sql.= " WHERE rowid = ".$selected; - } - $sql .= " ORDER BY nom ASC"; - - $resql = $object->db->query($sql); - if ($resql) - { - if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT) - { - $langs->load("companies"); - $obj = $this->db->fetch_object($resql); - $socid = $obj->rowid?$obj->rowid:''; - $javaScript = "window.location=\'./contact.php?".$var_id."=".$object->id."&".$htmlname."=\' + document.getElementById(\'newcompany_id\').value;"; - - // On applique un delai d'execution pour le bon fonctionnement - $htmloption = 'onChange="ac_delay(\''.$javaScript.'\',\'500\')"'; - - print ''; - print ''; - print ''; - print '
'; - print '
'; - if ($obj->rowid == 0) - { - print ''; - } - else - { - print ''; - } - print ajax_autocompleter($socid,'newcompany','/societe/ajaxcompanies.php',''); - print '
'; - print ajax_indicator($htmlname,'working'); - print '
'; - return $socid; - } - else - { - $javaScript = "window.location='./contact.php?".$var_id."=".$object->id."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; - print '\n"; - return $firstCompany; - } - } - else - { - dolibarr_print_error($object->db); - } - } - - -/** - * - */ - function selectTypeContact($object, $defValue, $htmlname = 'type', $source) - { - $lesTypes = $object->liste_type_contact($source); - print '\n"; - } - /** * \brief Load properties id_previous and id_next diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 6750dd2e717..fdc2d1cf35b 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -28,6 +28,7 @@ require ("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT.'/lib/invoice.lib.php'); +require_once(DOL_DOCUMENT_ROOT.'/html.formcompany.class.php'); $langs->load("facture"); $langs->load("companies"); @@ -144,6 +145,7 @@ if ($_GET["action"] == 'deleteline' && $user->rights->facture->creer) llxHeader('', $langs->trans("Bill"), "Facture"); $html = new Form($db); +$formcompany = new FormCompany($db); $contactstatic=new Contact($db); @@ -182,6 +184,7 @@ if ($id > 0) print ''; + /* * Lignes de contacts */ @@ -189,7 +192,7 @@ if ($id > 0) /* * Ajouter une ligne de contact - * Non affiché en mode modification de ligne + * Non affich� en mode modification de ligne */ if ($_GET["action"] != 'editline' && $user->rights->facture->creer) { @@ -220,12 +223,12 @@ if ($id > 0) print ''; print ''; - // On récupère les id des users déjà sélectionnés + // On r�cup�re les id des users d�j� s�lectionn�s //$userAlreadySelected = $facture->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type $html->select_users($user->id,'contactid',0,$userAlreadySelected); print ''; print ''; - $facture->selectTypeContact($facture, '', 'type','internal'); + $formcompany->selectTypeContact($facture, '', 'type','internal'); print ''; print ''; print ''; @@ -247,17 +250,16 @@ if ($id > 0) print ''; $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$facture->client->id; - $selectedCompany = $facture->selectCompaniesForNewContact($facture, 'facid', $selectedCompany, $htmlname = 'newcompany'); + $selectedCompany = $formcompany->selectCompaniesForNewContact($facture, 'facid', $selectedCompany, $htmlname = 'newcompany'); print ''; print ''; - // On récupère les id des contacts déjà sélectionnés - //$contactAlreadySelected = $facture->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type + //$contactAlreadySelected = $facture->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionne car on doit pouvoir le seclectionner une deuxieme fois pour un autre type $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid', 0, $contactAlreadySelected); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print ''; - $facture->selectTypeContact($facture, '', 'type','external'); + $formcompany->selectTypeContact($facture, '', 'type','external'); print ''; print ' 0) print ' '; } - // Liste des contacts liés + // List of linked contacts print ''; print ''.$langs->trans("Source").''; print ''.$langs->trans("Company").''; @@ -300,7 +302,7 @@ if ($id > 0) if ($tab[$i]['source']=='external') print $langs->trans("ThirdPartyContact"); print ''; - // Societe + // Third party print ''; if ($tab[$i]['socid'] > 0) { @@ -332,18 +334,18 @@ if ($id > 0) } print ''; - // Type de contact + // Type of contact print ''.$tab[$i]['libelle'].''; - // Statut + // Status print ''; - // Activation desativation du contact + // Activate/Unactivate contact if ($facture->statut >= 0) print ''; print $contactstatic->LibStatut($tab[$i]['status'],3); if ($facture->statut >= 0) print ''; print ''; - // Icon update et delete (statut contrat 0=brouillon,1=validé,2=fermé) + // Icon update et delete print ''; if ($user->rights->facture->creer) { @@ -363,8 +365,8 @@ if ($id > 0) } else { - // Contrat non trouvé - print "Contrat inexistant ou accés refusé"; + // Record not found + print "ErrorRecordNotFound"; } } diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 22600eece31..32bf04c32b8 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -28,6 +28,7 @@ require ("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/lib/contract.lib.php'); require_once(DOL_DOCUMENT_ROOT."/contrat/contrat.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); +require_once(DOL_DOCUMENT_ROOT.'/html.formcompany.class.php'); $langs->load("contracts"); @@ -143,10 +144,14 @@ if ($_GET["action"] == 'deleteline' && $user->rights->contrat->creer) } +/* + * View + */ llxHeader('', $langs->trans("ContractCard"), "Contrat"); $html = new Form($db); +$formcompany= new FormCompany($db); $contactstatic=new Contact($db); @@ -210,7 +215,7 @@ if ($id > 0) /* * Ajouter une ligne de contact - * Non affiché en mode modification de ligne + * Non affich� en mode modification de ligne */ if ($_GET["action"] != 'editline' && $user->rights->contrat->creer) { @@ -241,12 +246,11 @@ if ($id > 0) print ''; print ''; - // On récupère les id des users déjà sélectionnés //$userAlreadySelected = $contrat->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type $html->select_users($user->id,'contactid',0,$userAlreadySelected); print ''; print ''; - $contrat->selectTypeContact($contrat, '', 'type','internal'); + $formcompany->selectTypeContact($contrat, '', 'type','internal'); print ''; print ''; print ''; @@ -268,17 +272,16 @@ if ($id > 0) print ''; $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$contrat->societe->id; - $selectedCompany = $contrat->selectCompaniesForNewContact($contrat, 'id', $selectedCompany, $htmlname = 'newcompany'); + $selectedCompany = $formcompany->selectCompaniesForNewContact($contrat, 'id', $selectedCompany, 'newcompany'); print ''; print ''; - // On récupère les id des contacts déjà sélectionnés //$contactAlreadySelected = $contrat->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type $nbofcontacts=$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print ''; - $contrat->selectTypeContact($contrat, '', 'type','external'); + $formcompany->selectTypeContact($contrat, '', 'type','external'); print ''; print ' 0) print ' '; - // Liste des contacts liés + // Liste des contacts li�s print ''; print ''.$langs->trans("Source").''; print ''.$langs->trans("Company").''; @@ -365,9 +368,9 @@ if ($id > 0) if ($contrat->statut >= 0) print ''; print ''; - // Icon update et delete (statut contrat 0=brouillon,1=validé,2=fermé) + // Icon delete print ''; - if ($contrat->statut == 0 && $user->rights->contrat->creer) + if ($user->rights->contrat->creer) { print ' '; print ''; @@ -387,8 +390,7 @@ if ($id > 0) } else { - // Contrat non trouvé - print "Contrat inexistant ou accés refusé"; + print "ErrorRecordNotFound"; } } diff --git a/htdocs/fichinter/contact.php b/htdocs/fichinter/contact.php index 1c927677682..0974b118e40 100644 --- a/htdocs/fichinter/contact.php +++ b/htdocs/fichinter/contact.php @@ -18,16 +18,17 @@ */ /** - \file htdocs/fichinter/contact.php - \ingroup fichinter - \brief Onglet de gestion des contacts de fiche d'intervention - \version $Id$ -*/ + * \file htdocs/fichinter/contact.php + * \ingroup fichinter + * \brief Onglet de gestion des contacts de fiche d'intervention + * \version $Id$ + */ require ("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/fichinter/fichinter.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/fichinter.lib.php"); +require_once(DOL_DOCUMENT_ROOT.'/html.formcompany.class.php'); $langs->load("interventions"); $langs->load("sendings"); @@ -142,9 +143,14 @@ if ($_GET["action"] == 'deleteline' && $user->rights->ficheinter->creer) } +/* + * View + */ + llxHeader(); $html = new Form($db); +$formcompany = new FormCompany($db); $contactstatic=new Contact($db); @@ -196,7 +202,7 @@ if ($id > 0) /* * Ajouter une ligne de contact - * Non affiché en mode modification de ligne + * Non affiche en mode modification de ligne */ if ($_GET["action"] != 'editline' && $user->rights->ficheinter->creer) { @@ -227,12 +233,11 @@ if ($id > 0) print ''; print ''; - // On récupère les id des users déjà sélectionnés //$userAlreadySelected = $fichinter->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type $html->select_users($user->id,'contactid',0,$userAlreadySelected); print ''; print ''; - $fichinter->selectTypeContact($fichinter, '', 'type','internal'); + $formcompany->selectTypeContact($fichinter, '', 'type','internal'); print ''; print ''; print ''; @@ -254,17 +259,16 @@ if ($id > 0) print ''; $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$fichinter->client->id; - $selectedCompany = $fichinter->selectCompaniesForNewContact($fichinter, 'id', $selectedCompany, $htmlname = 'newcompany'); + $selectedCompany = $formcompany->selectCompaniesForNewContact($fichinter, 'id', $selectedCompany, $htmlname = 'newcompany'); print ''; print ''; - // On récupère les id des contacts déjà sélectionnés //$contactAlreadySelected = $fichinter->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type $nbofcontacts=$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print ''; - $fichinter->selectTypeContact($fichinter, '', 'type','external'); + $formcompany->selectTypeContact($fichinter, '', 'type','external'); print ''; print ' 0) print ' '; } - // Liste des contacts liés + // Liste des contacts li�s print ''; print ''.$langs->trans("Source").''; print ''.$langs->trans("Company").''; @@ -370,8 +374,7 @@ if ($id > 0) } else { - // Fiche intervention non trouvée - print "Fiche intervention inexistante ou accès refusé"; + print "ErrorRecordNotFound"; } } diff --git a/htdocs/fourn/commande/contact.php b/htdocs/fourn/commande/contact.php index 0783886c8b0..9c815a96b89 100644 --- a/htdocs/fourn/commande/contact.php +++ b/htdocs/fourn/commande/contact.php @@ -28,6 +28,7 @@ require ("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.commande.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once DOL_DOCUMENT_ROOT."/lib/fourn.lib.php"; +require_once(DOL_DOCUMENT_ROOT.'/html.formcompany.class.php'); $langs->load("facture"); $langs->load("orders"); @@ -151,6 +152,7 @@ if ($_GET["action"] == 'deleteline' && $user->rights->commande->creer) llxHeader('', $langs->trans("Order"), "Commande"); $html = new Form($db); +$formcompany = new FormCompany($db); $contactstatic=new Contact($db); @@ -205,7 +207,7 @@ if ($id > 0 || ! empty($ref)) /* * Ajouter une ligne de contact - * Non affiché en mode modification de ligne + * Non affich� en mode modification de ligne */ if ($_GET["action"] != 'editline' && $user->rights->fournisseur->facture->creer) { @@ -238,12 +240,11 @@ if ($id > 0 || ! empty($ref)) print ''; print ''; - // On récupère les id des users déjà sélectionnés //$userAlreadySelected = $commande->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type $html->select_users($user->id,'contactid',0,$userAlreadySelected); print ''; print ''; - $commande->selectTypeContact($commande, '', 'type','internal'); + $formcompany->selectTypeContact($commande, '', 'type','internal'); print ''; print ''; print ''; @@ -265,17 +266,16 @@ if ($id > 0 || ! empty($ref)) print ''; $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$commande->client->id; - $selectedCompany = $commande->selectCompaniesForNewContact($commande, 'id', $selectedCompany, $htmlname = 'newcompany'); + $selectedCompany = $formcompany->selectCompaniesForNewContact($commande, 'id', $selectedCompany, 'newcompany'); print ''; print ''; - // On récupère les id des contacts déjà sélectionnés // $contactAlreadySelected = $commande->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type $nbofcontacts=$html->select_contacts($selectedCompany, $selected = '', $htmlname = 'contactid',0,$contactAlreadySelected); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print ''; - $commande->selectTypeContact($commande, '', 'type','external'); + $formcompany->selectTypeContact($commande, '', 'type','external'); print ''; print ' 0 || ! empty($ref)) print ' '; } - // Liste des contacts liés + // List of linked contacts print ''; print ''.$langs->trans("Source").''; print ''.$langs->trans("Company").''; diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index ddc9c9dfe7e..c4decbd5657 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -51,7 +51,7 @@ $comclientid = isset($_GET["comid"])?$_GET["comid"]:''; $id = isset($_GET["id"])?$_GET["id"]:$_POST["id"]; // Securite acces client -$socid=0; +$socid = isset($_GET["socid"])?$_GET["socid"]:''; if ($user->societe_id > 0) { $action = ''; @@ -140,7 +140,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->fournisseur->commande->cree $_POST['idprodfournprice'], $prodfournprice->fourn_ref, $_POST['remise_percent'], - 'HT' + 'HT' ); } @@ -209,13 +209,13 @@ if ($_POST['action'] == 'updateligne' && $user->rights->fournisseur->commande->c if ($result >= 0) { - $outputlangs = $langs; - if (! empty($_REQUEST['lang_id'])) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($_REQUEST['lang_id']); - } - supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + $outputlangs = $langs; + if (! empty($_REQUEST['lang_id'])) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); } else { @@ -431,11 +431,12 @@ if ($action=='remove_file') if ($_GET["action"] == 'create') { $fourn = new Fournisseur($db); - $fourn->fetch($_GET["socid"]); + $result=$fourn->fetch($_GET["socid"]); $db->begin(); $orderid=$fourn->create_commande($user); + if ($orderid > 0) { $idc = $fourn->single_open_commande; @@ -447,6 +448,7 @@ if ($_GET["action"] == 'create') } $id=$orderid; + $_GET['id']=$id; $_GET['action']='edit'; $db->commit(); } diff --git a/htdocs/fourn/facture/contact.php b/htdocs/fourn/facture/contact.php index 5aa47398175..8defab0ad4d 100644 --- a/htdocs/fourn/facture/contact.php +++ b/htdocs/fourn/facture/contact.php @@ -28,6 +28,7 @@ require ("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.facture.class.php"); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); require_once(DOL_DOCUMENT_ROOT.'/lib/fourn.lib.php'); +require_once(DOL_DOCUMENT_ROOT.'/html.formcompany.class.php'); $langs->load("facture"); $langs->load("companies"); @@ -148,6 +149,7 @@ if ($_GET["action"] == 'deleteline' && $user->rights->fournisseur->facture->cree llxHeader('', $langs->trans("Bill"), "Facture"); $html = new Form($db); +$formcompany = new FormCompany($db); $contactstatic=new Contact($db); @@ -228,12 +230,11 @@ if ($id > 0) print ''; print ''; - // On r�cup�re les id des users d�j� s�lectionn�s //$userAlreadySelected = $facture->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type $html->select_users($user->id,'contactid',0,$userAlreadySelected); print ''; print ''; - $facture->selectTypeContact($facture, '', 'type','internal'); + $formcompany->selectTypeContact($facture, '', 'type','internal'); print ''; print ''; print ''; @@ -255,17 +256,16 @@ if ($id > 0) print ''; $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$facture->client->id; - $selectedCompany = $facture->selectCompaniesForNewContact($facture, 'facid', $selectedCompany, $htmlname = 'newcompany'); + $selectedCompany = $formcompany->selectCompaniesForNewContact($facture, 'facid', $selectedCompany, $htmlname = 'newcompany'); print ''; print ''; - // On r�cup�re les id des contacts d�j� s�lectionn�s //$contactAlreadySelected = $facture->getListContactId('external'); // On ne doit pas desactiver un contact deja selectionner car on doit pouvoir le seclectionner une deuxieme fois pour un autre type $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid', 0, $contactAlreadySelected); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; print ''; - $facture->selectTypeContact($facture, '', 'type','external'); + $formcompany->selectTypeContact($facture, '', 'type','external'); print ''; print ' 0) print ' '; } - // Liste des contacts lies + // List of linked contacts print ''; print ''.$langs->trans("Source").''; print ''.$langs->trans("Company").''; @@ -371,7 +371,7 @@ if ($id > 0) } else { - print "Object not found"; + print "ErrorRecordNotFound"; } } diff --git a/htdocs/fourn/fiche.php b/htdocs/fourn/fiche.php index 1916f4c3c8f..a3b8b3c91e2 100644 --- a/htdocs/fourn/fiche.php +++ b/htdocs/fourn/fiche.php @@ -20,11 +20,11 @@ */ /** - \file htdocs/fourn/fiche.php - \ingroup fournisseur, facture - \brief Page de fiche fournisseur - \version $Id$ -*/ + \file htdocs/fourn/fiche.php + \ingroup fournisseur, facture + \brief Page de fiche fournisseur + \version $Id$ + */ require('./pre.inc.php'); require_once(DOL_DOCUMENT_ROOT."/contact.class.php"); @@ -46,89 +46,89 @@ $result = restrictedArea($user, 'societe',$socid,''); /* * View - */ + */ $societe = new Fournisseur($db); $contactstatic = new Contact($db); $form = new Form($db); if ( $societe->fetch($socid) ) { - $addons[0][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$socid; - $addons[0][1] = $societe->nom; - - llxHeader('',$langs->trans('SupplierCard').' : '.$societe->nom, $addons); - - /* - * Affichage onglets - */ - $head = societe_prepare_head($societe); - - dolibarr_fiche_head($head, 'supplier', $langs->trans("ThirdParty")); - - - print ''; - print '
'; - - print ''; - print ''; - - print ''; - - if ($societe->fournisseur) - { - print ''; - } - - print ''; - - print ''; - print ''; - - // Country - print ''; + $addons[0][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$socid; + $addons[0][1] = $societe->nom; - print ''; - print ''; - print '"; - - // Assujetti a TVA ou pas - print ''; - print ''; - print ''; - - print '
'.$langs->trans("Name").''.$societe->nom.'
'.$langs->trans('Prefix').''.$societe->prefix_comm.'
'; - print $langs->trans('SupplierCode').''; - print $societe->code_fournisseur; - if ($societe->check_codefournisseur() <> 0) print ' '.$langs->trans("WrongSupplierCode"); - print '
'.$langs->trans("Address").''.nl2br($societe->adresse).'
'.$langs->trans("Zip").''.$societe->cp.''.$langs->trans("Town").''.$societe->ville.'
'.$langs->trans("Country").''; - if ($societe->isInEEC()) print $form->textwithhelp($societe->pays,$langs->trans("CountryIsInEEC"),1,0); - else print $societe->pays; - print '
'.$langs->trans("Phone").''.dol_print_phone($societe->tel,$societe->pays_code,0,$societe->id,'AC_TEL').''.$langs->trans("Fax").''.dol_print_phone($societe->fax,$societe->pays_code,0,$societe->id,'AC_FAX').'
'.$langs->trans("Web")."url\">$societe->url 
'.$langs->trans('VATIsUsed').''; - print yn($societe->tva_assuj); - print '
'; - - - print '
'; - $var=true; - - $MAXLIST=5; - - // Lien recap - print ''; - print ''; - print ''; - print ''; - print '
'; - print '
'.$langs->trans("Summary").''.$langs->trans("ShowSupplierPreview").'
'; - print '
'; - - /* - * Liste des commandes associees - */ - $orderstatic = new CommandeFournisseur($db); - - $sql = "SELECT p.rowid,p.ref,".$db->pdate("p.date_commande")." as dc, p.fk_statut"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p "; + llxHeader('',$langs->trans('SupplierCard').' : '.$societe->nom, $addons); + + /* + * Affichage onglets + */ + $head = societe_prepare_head($societe); + + dolibarr_fiche_head($head, 'supplier', $langs->trans("ThirdParty")); + + + print ''; + print '
'; + + print ''; + print ''; + + print ''; + + if ($societe->fournisseur) + { + print ''; + } + + print ''; + + print ''; + print ''; + + // Country + print ''; + + print ''; + print ''; + print '"; + + // Assujetti a TVA ou pas + print ''; + print ''; + print ''; + + print '
'.$langs->trans("Name").''.$societe->nom.'
'.$langs->trans('Prefix').''.$societe->prefix_comm.'
'; + print $langs->trans('SupplierCode').''; + print $societe->code_fournisseur; + if ($societe->check_codefournisseur() <> 0) print ' '.$langs->trans("WrongSupplierCode"); + print '
'.$langs->trans("Address").''.nl2br($societe->adresse).'
'.$langs->trans("Zip").''.$societe->cp.''.$langs->trans("Town").''.$societe->ville.'
'.$langs->trans("Country").''; + if ($societe->isInEEC()) print $form->textwithhelp($societe->pays,$langs->trans("CountryIsInEEC"),1,0); + else print $societe->pays; + print '
'.$langs->trans("Phone").''.dol_print_phone($societe->tel,$societe->pays_code,0,$societe->id,'AC_TEL').''.$langs->trans("Fax").''.dol_print_phone($societe->fax,$societe->pays_code,0,$societe->id,'AC_FAX').'
'.$langs->trans("Web")."url\">$societe->url 
'.$langs->trans('VATIsUsed').''; + print yn($societe->tva_assuj); + print '
'; + + + print '
'; + $var=true; + + $MAXLIST=5; + + // Lien recap + print ''; + print ''; + print ''; + print ''; + print '
'; + print '
'.$langs->trans("Summary").''.$langs->trans("ShowSupplierPreview").'
'; + print '
'; + + /* + * Liste des commandes associees + */ + $orderstatic = new CommandeFournisseur($db); + + $sql = "SELECT p.rowid,p.ref,".$db->pdate("p.date_commande")." as dc, p.fk_statut"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p "; $sql.= " WHERE p.fk_soc =".$societe->id; $sql.= " ORDER BY p.date_commande DESC"; $sql.= " ".$db->plimit($MAXLIST); @@ -268,10 +268,10 @@ if ( $societe->fetch($socid) ) } if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) - { + { print ''.$langs->trans("AddAction").''; - } - + } + if ($user->rights->societe->contact->creer) { print "".$langs->trans("AddContact").""; @@ -281,18 +281,18 @@ if ( $societe->fetch($socid) ) print '
'; /* - * Liste des contacts - */ + * Liste des contacts + */ show_contacts($conf,$langs,$db,$societe); - /* - * Listes des actions a faire - */ + /* + * Listes des actions a faire + */ show_actions_todo($conf,$langs,$db,$societe); - - /* - * Listes des actions effectuees - */ + + /* + * Listes des actions effectuees + */ show_actions_done($conf,$langs,$db,$societe); } else diff --git a/htdocs/html.formcompany.class.php b/htdocs/html.formcompany.class.php index 30de61abf8b..0762ba72148 100644 --- a/htdocs/html.formcompany.class.php +++ b/htdocs/html.formcompany.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2008-2009 Laurent Destailleur * * 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 @@ -18,14 +18,14 @@ /** * \file htdocs/html.formcompany.class.php - * \brief Fichier de la classe des fonctions pr�d�finie de composants html + * \brief File of class to build HTML component for third parties management * \version $Id$ */ /** * \class FormCompany - * \brief Classe permettant la g�n�ration de composants html + * \brief Class to build HTML component for third parties management * \remarks Only common components must be here. */ class FormCompany @@ -256,7 +256,7 @@ class FormCompany } } - + /** * \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 @@ -309,13 +309,13 @@ class FormCompany } print ''; } - else + else { dolibarr_print_error($this->db); } } - + /** * \brief Retourne la liste d�roulante des civilite actives * \param selected civilite pr�-s�lectionn�e @@ -436,6 +436,109 @@ class FormCompany } } + + /** + * \brief Return list of third parties + * \param object Object we try to find contacts + * \param var_id Name of id field + * \param selected Pre-selected third party + * \param htmlname Name of HTML form + */ + function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany') + { + global $conf, $langs; + + // On recherche les societes + $sql = "SELECT s.rowid, s.nom FROM"; + $sql .= " ".MAIN_DB_PREFIX."societe as s"; + if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT) + { + $sql.= " WHERE rowid = ".$selected; + } + $sql .= " ORDER BY nom ASC"; + + $resql = $object->db->query($sql); + if ($resql) + { + if ($conf->use_javascript_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT) + { + $langs->load("companies"); + $obj = $this->db->fetch_object($resql); + $socid = $obj->rowid?$obj->rowid:''; + $javaScript = "window.location=\'./contact.php?".$var_id."=".$object->id."&".$htmlname."=\' + document.getElementById(\'newcompany_id\').value;"; + + // On applique un delai d'execution pour le bon fonctionnement + $htmloption = 'onChange="ac_delay(\''.$javaScript.'\',\'500\')"'; + + print ''; + print ''; + print ''; + print '
'; + print '
'; + if ($obj->rowid == 0) + { + print ''; + } + else + { + print ''; + } + print ajax_autocompleter($socid,'newcompany','/societe/ajaxcompanies.php',''); + print '
'; + print ajax_indicator($htmlname,'working'); + print '
'; + return $socid; + } + else + { + $javaScript = "window.location='./contact.php?".$var_id."=".$object->id."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; + print '\n"; + return $firstCompany; + } + } + else + { + dolibarr_print_error($object->db); + } + } + + + /** + * + */ + function selectTypeContact($object, $defValue, $htmlname = 'type', $source) + { + $lesTypes = $object->liste_type_contact($source); + print '\n"; + } + + } ?>