diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 1f81f38594482..01a40150a05d8 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -502,14 +502,15 @@ function select_juridicalstatus($selected='', $country_codeid=0, $filter='') /** * Return list of third parties * - * @param Object $object Object we try to find contacts - * @param string $var_id Name of id field - * @param string $selected Pre-selected third party - * @param string $htmlname Name of HTML form - * @param string $limitto Disable answers that are not id in this array list + * @param Object $object Object we try to find contacts + * @param string $var_id Name of id field + * @param string $selected Pre-selected third party + * @param string $htmlname Name of HTML form + * @param string $limitto Disable answers that are not id in this array list + * @param int $forceid This is to force antoher object id than object->id * @return void */ - function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname='newcompany', $limitto='') + function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname='newcompany', $limitto='', $forceid=0) { global $conf, $langs; @@ -544,7 +545,7 @@ function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname= } // We call a page after a small delay when a new input has been selected - $javaScript = "window.location=\'./contact.php?".$var_id."=".$object->id."&".$htmlname."=\' + document.getElementById(\'".$htmlname."\').value;"; + $javaScript = "window.location=\'./contact.php?".$var_id."=".($forceid>0?$forceid:$object->id)."&".$htmlname."=\' + document.getElementById(\'".$htmlname."\').value;"; $htmloption = 'onChange="ac_delay(\''.$javaScript.'\',\'500\');"'; // When we select with mouse $htmloption.= 'onKeyUp="if (event.keyCode== 13) { ac_delay(\''.$javaScript.'\',\'500\'); }"'; // When we select with keyboard @@ -570,7 +571,7 @@ function selectCompaniesForNewContact($object, $var_id, $selected='', $htmlname= } else { - $javaScript = "window.location='./contact.php?".$var_id."=".$object->id."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; + $javaScript = "window.location='./contact.php?".$var_id."=".($forceid>0?$forceid:$object->id)."&".$htmlname."=' + form.".$htmlname.".options[form.".$htmlname.".selectedIndex].value;"; print ''; + print ''; + print ''; + print ''; + + // Ligne ajout pour contact interne + print ''; + + print ''; + print img_object('','user').' '.$langs->trans("Users"); + print ''; + + print ''; + print $conf->global->MAIN_INFO_SOCIETE_NOM; + print ''; + + print ''; + //$userAlreadySelected = $object->getListContactId('internal'); // On ne doit pas desactiver un contact deja selectionne car on doit pouvoir le selectionner une deuxieme fois pour un autre type + $form->select_users($user->id,'contactid',0,$userAlreadySelected); + print ''; + print ''; + $formcompany->selectTypeContact($objectsrc, '', 'type','internal'); + print ''; + print ''; + print ''; + + print ''; + + print '
'; + print ''; + print ''; + print ''; + print ''; + + // Ligne ajout pour contact externe + $var=!$var; + print ''; + + print ''; + print img_object('','contact').' '.$langs->trans("ThirdPartyContacts"); + print ''; + + print ''; + $selectedCompany = isset($_GET["newcompany"])?$_GET["newcompany"]:$object->client->id; + $selectedCompany = $formcompany->selectCompaniesForNewContact($objectsrc, 'id', $selectedCompany, 'newcompany', '', $object->id); + print ''; + + print ''; + $nbofcontacts=$form->select_contacts($selectedCompany, '', 'contactid'); + if ($nbofcontacts == 0) print $langs->trans("NoContactDefined"); + print ''; + print ''; + + $formcompany->selectTypeContact($objectsrc, '', 'type','external'); + print ''; + print ''; + print ''; + + print "
"; + + print ' '; + } + + // List of linked contacts + print ''; + print ''.$langs->trans("Source").''; + print ''.$langs->trans("Company").''; + print ''.$langs->trans("Contacts").''; + print ''.$langs->trans("ContactType").''; + print ''.$langs->trans("Status").''; + print ' '; + print "\n"; + + $companystatic=new Societe($db); + $var = true; + + foreach(array('internal','external') as $source) + { + $tab = $objectsrc->liste_contact(-1,$source); + $num=count($tab); + + $i = 0; + while ($i < $num) + { + $var = !$var; + + print ''; + + // Source + print ''; + if ($tab[$i]['source']=='internal') print $langs->trans("User"); + if ($tab[$i]['source']=='external') print $langs->trans("ThirdPartyContact"); + print ''; + + // Societe + print ''; + if ($tab[$i]['socid'] > 0) + { + $companystatic->fetch($tab[$i]['socid']); + print $companystatic->getNomUrl(1); + } + if ($tab[$i]['socid'] < 0) + { + print $conf->global->MAIN_INFO_SOCIETE_NOM; + } + if (! $tab[$i]['socid']) + { + print ' '; + } + print ''; + + // Contact + print ''; + if ($tab[$i]['source']=='internal') + { + $userstatic->id=$tab[$i]['id']; + $userstatic->lastname=$tab[$i]['lastname']; + $userstatic->firstname=$tab[$i]['firstname']; + print $userstatic->getNomUrl(1); + } + if ($tab[$i]['source']=='external') + { + $contactstatic->id=$tab[$i]['id']; + $contactstatic->lastname=$tab[$i]['lastname']; + $contactstatic->firstname=$tab[$i]['firstname']; + print $contactstatic->getNomUrl(1); + } + print ''; + + // Type de contact + print ''.$tab[$i]['libelle'].''; + + // Statut + print ''; + // Activation desativation du contact + if ($object->statut >= 0) print ''; + print $contactstatic->LibStatut($tab[$i]['status'],3); + if ($object->statut >= 0) print ''; + print ''; + + // Icon update et delete + print ''; + if ($object->statut < 5 && $user->rights->expedition->creer) + { + print ' '; + print ''; + print img_delete(); + print ''; + } + print ''; + + print "\n"; + + $i ++; + } + } + print ""; +} + +llxFooter(); + +$db->close(); +?> \ No newline at end of file diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 5937cfba5901b..d5d3406611a59 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -656,7 +656,7 @@ } -$db->close(); - llxFooter(); + +$db->close(); ?>