From a0bd7d2f6110c8f70dce776502e6bc35caf8c515 Mon Sep 17 00:00:00 2001 From: Philippe Grand Date: Fri, 29 Apr 2011 16:18:22 +0000 Subject: [PATCH] uniformize code and fix some display issue --- htdocs/comm/propal/contact.php | 57 +++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index fec9b2e0421..ad5c864b9cc 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -35,7 +35,12 @@ $langs->load("orders"); $langs->load("sendings"); $langs->load("companies"); -$id = isset($_GET["id"])?$_GET["id"]:''; +$id=GETPOST('id'); +$ligne=GETPOST('ligne'); +$lineid=GETPOST('lineid'); +$action=GETPOST('action'); + +$id = isset($id)?$id:''; // Security check if ($user->societe_id) $socid=$user->societe_id; @@ -51,9 +56,9 @@ if ($_POST["action"] == 'addcontact' && $user->rights->propale->creer) $result = 0; $propal = new Propal($db); - $result = $propal->fetch($_GET["id"]); + $result = $propal->fetch($id); - if ($result > 0 && $_GET["id"] > 0) + if ($result > 0 && $id > 0) { $result = $propal->add_contact($_POST["contactid"], $_POST["type"], $_POST["source"]); } @@ -80,7 +85,7 @@ if ($_POST["action"] == 'addcontact' && $user->rights->propale->creer) if ($_POST["action"] == 'updateligne' && $user->rights->propale->creer) { $propal = new Propal($db); - if ($propal->fetch($_GET["id"])) + if ($propal->fetch($id)) { $contact = $propal->detail_contact($_POST["elrowid"]); $type = $_POST["type"]; @@ -102,16 +107,16 @@ if ($_POST["action"] == 'updateligne' && $user->rights->propale->creer) } // bascule du statut d'un contact -if ($_GET["action"] == 'swapstatut' && $user->rights->propale->creer) +if ($action == 'swapstatut' && $user->rights->propale->creer) { $propal = new Propal($db); - if ($propal->fetch($_GET["id"])) + if ($propal->fetch($id)) { - $contact = $propal->detail_contact($_GET["ligne"]); + $contact = $propal->detail_contact($ligne); $id_type_contact = $contact->fk_c_type_contact; $statut = ($contact->statut == 4) ? 5 : 4; - $result = $propal->update_contact($_GET["ligne"], $statut, $id_type_contact); + $result = $propal->update_contact($ligne, $statut, $id_type_contact); if ($result >= 0) { $db->commit(); @@ -127,11 +132,11 @@ if ($_GET["action"] == 'swapstatut' && $user->rights->propale->creer) } // Efface un contact -if ($_GET["action"] == 'deleteline' && $user->rights->propale->creer) +if ($action == 'deleteline' && $user->rights->propale->creer) { $propal = new Propal($db); - $propal->fetch($_GET["id"]); - $result = $propal->delete_contact($_GET["lineid"]); + $propal->fetch($id); + $result = $propal->delete_contact($lineid); if ($result >= 0) { @@ -163,8 +168,8 @@ $userstatic=new User($db); /* *************************************************************************** */ if (isset($mesg)) print $mesg; -$id = $_GET["id"]; -$ref= $_GET["ref"]; +$id = $id; +$ref= GETPOST('ref'); if ($id > 0 || ! empty($ref)) { $propal = New Propal($db); @@ -222,7 +227,7 @@ if ($id > 0 || ! empty($ref)) * Ajouter une ligne de contact * Non affiche en mode modification de ligne */ - if ($_GET["action"] != 'editline' && $user->rights->propale->creer) + if ($action != 'editline' && $user->rights->propale->creer) { print ''; print ''.$langs->trans("Source").''; @@ -241,19 +246,19 @@ if ($id > 0 || ! empty($ref)) print ''; // Ligne ajout pour contact interne - print ""; + print ''; print ''; print img_object('','user').' '.$langs->trans("Users"); print ''; - print ''; + print ''; print $conf->global->MAIN_INFO_SOCIETE_NOM; print ''; - print ''; + print ''; // On recupere les id des users deja selectionnes - //$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 + //$userAlreadySelected = $propal->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionne car on doit pouvoir le selectionner une deuxieme fois pour un autre type $html->select_users($user->id,'contactid',0,$userAlreadySelected); print ''; print ''; @@ -272,18 +277,18 @@ if ($id > 0 || ! empty($ref)) // Ligne ajout pour contact externe $var=!$var; - print ""; + print ''; print ''; print img_object('','contact').' '.$langs->trans("ThirdPartyContacts"); print ''; - print ''; + print ''; $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$propal->client->id; $selectedCompany = $formcompany->selectCompaniesForNewContact($propal, 'id', $selectedCompany, 'newcompany'); print ''; - print ''; + print ''; $nbofcontacts=$html->select_contacts($selectedCompany, '', 'contactid'); if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); print ''; @@ -295,19 +300,21 @@ if ($id > 0 || ! empty($ref)) print '>'; print ''; - print ""; + print ''; print ' '; + print ''; } + print ''; + // Liste des contacts lies print ''; print ''; print ''; print ''; print ''; - print ''; - print ''; + print ''; print "\n"; $companystatic = new Societe($db); @@ -378,7 +385,7 @@ if ($id > 0 || ! empty($ref)) print ''; // Icon update et delete - print '
'.$langs->trans("Source").''.$langs->trans("Company").''.$langs->trans("Contacts").''.$langs->trans("ContactType").''.$langs->trans("Status").' '.$langs->trans("Status").'
'; + print ''; if ($user->rights->propale->creer) { print ' ';