diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index d14503a9039..b4ada747d2c 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -28,7 +28,6 @@ if (empty($object) || !is_object($object)) exit; } - require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; @@ -66,8 +65,9 @@ $userstatic = new User($db);
+if ($permission) +{ + ?>
trans("NatureOfContact"); ?>
trans("ThirdParty"); ?>
@@ -153,94 +153,180 @@ if ($permission) { - -
trans("NatureOfContact"); ?>
-
trans("ThirdParty"); ?>
-
trans("Users").'/'.$langs->trans("Contacts"); ?>
-
trans("ContactType"); ?>
-
trans("Status"); ?>
-
 
-
+print "
"; -element == 'shipping'|| $object->element == 'reception') && is_object($objectsrc)) $tmpobject=$objectsrc; +/** +* Prepare list +*/ + +// TODO: replace this with direct SQL string to use $db->sort($sortfield, $sortorder) +$list = array(); +foreach(array('internal', 'external') as $source) +{ + $tmpobject = $object; + + if (($object->element == 'shipping'|| $object->element == 'reception') && is_object($objectsrc)) + { + $tmpobject = $objectsrc; + } $tab = $tmpobject->liste_contact(-1, $source); - $num=count($tab); + $num = count($tab); $i = 0; - while ($i < $num) { - ?> + while ($i < $num) + { + $entry = ''; + $entry->id = $tab[$i]['rowid']; + $entry->type = $tab[$i]['libelle']; + + if ($tab[$i]['source'] == 'internal') + { + $entry->nature = $langs->trans("User"); + } + elseif ($tab[$i]['source'] == 'external') + { + $entry->nature = $langs->trans("ThirdPartyContact"); + } -
-
- trans("User"); ?> - trans("ThirdPartyContact"); ?> -
-
- 0) { $companystatic->fetch($tab[$i]['socid']); - echo $companystatic->getNomUrl(1); + $entry->thirdparty = $companystatic->getNomUrl(1); } - if ($tab[$i]['socid'] < 0) + elseif ($tab[$i]['socid'] < 0) { - echo $conf->global->MAIN_INFO_SOCIETE_NOM; + $entry->thirdparty = $conf->global->MAIN_INFO_SOCIETE_NOM; } - if (! $tab[$i]['socid']) + elseif (! $tab[$i]['socid']) { - echo ' '; + $entry->thirdparty = ""; } - ?> -
-
- fetch($tab[$i]['id']); - echo $userstatic->getNomUrl(-1, '', 0, 0, 0, 0, '', 'valignmiddle'); + $entry->contact = $userstatic->getNomUrl(-1, '', 0, 0, 0, 0, '', 'valignmiddle'); } - if ($tab[$i]['source']=='external') + elseif ($tab[$i]['source']=='external') { $contactstatic->fetch($tab[$i]['id']); - echo $contactstatic->getNomUrl(1, '', 0, '', 0, 0); + $entry->contact =$contactstatic->getNomUrl(1, '', 0, '', 0, 0); } - ?> -
-
-
- statut >= 0) echo ''; + if ($tab[$i]['source']=='internal') { - echo $userstatic->LibStatut($tab[$i]['statuscontact'], 3); + $entry->status = $userstatic->LibStatut($tab[$i]['statuscontact'], 3); } - if ($tab[$i]['source']=='external') + elseif ($tab[$i]['source']=='external') { - echo $contactstatic->LibStatut($tab[$i]['statuscontact'], 3); + $entry->status = $contactstatic->LibStatut($tab[$i]['statuscontact'], 3); } - //if ($object->statut >= 0) echo ''; ?> -
-
- -  ">trans('Unlink'), 'unlink'); ?> - -
-
- \n"; -print "\n"; + +$sortfield = GETPOST("sortfield", "alpha"); +$sortorder = GETPOST("sortorder", 'alpha'); + +if (!$sortfield) $sortfield = "nature"; +if (!$sortorder) $sortorder = "asc"; + +/** + * Re-sort list + */ + +// TODO: switch to $db->sort($sortfield, $sortorder); +if($sortorder == "asc") +{ + if($sortfield == "nature") usort($list, "nature_asc"); + if($sortfield == "thirdparty") usort($list, "thirdparty_asc"); + if($sortfield == "contact") usort($list, "contact_asc"); + if($sortfield == "type") usort($list, "type_asc"); + if($sortfield == "status") usort($list, "status_asc"); +} +else +{ + if($sortfield == "nature") usort($list, "nature_desc"); + if($sortfield == "thirdparty") usort($list, "thirdparty_desc"); + if($sortfield == "contact") usort($list, "contact_desc"); + if($sortfield == "type") usort($list, "type_desc"); + if($sortfield == "status") usort($list, "status_desc"); +} + +$arrayfields = array( + 'rowid' => array('label'=>$langs->trans("Id"), 'checked'=>1), + 'nature' => array('label'=>$langs->trans("NatureOfContact"), 'checked'=>1), + 'thirdparty' => array('label'=>$langs->trans("ThirdParty"), 'checked'=>1), + 'contact' => array('label'=>$langs->trans("Users").'/'.$langs->trans("Contacts"), 'checked'=>1), + 'type' => array('label'=>$langs->trans("ContactType"), 'checked'=>1), + 'status' => array('label'=>$langs->trans("Status"), 'checked'=>1), + 'link' => array('label'=>$langs->trans("Link"), 'checked'=>1), +); + +$param = 'id='.$object->id.'&mainmenu=home'; + +/** + * Show list + */ + +print '
'; +print ''; +print ''; +print ''; +print ''; +print ''; + +print ''; + +print ''; +print ''; + +print ''; +print_liste_field_titre($arrayfields['nature']['label'], $_SERVER["PHP_SELF"], "nature", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre($arrayfields['thirdparty']['label'], $_SERVER["PHP_SELF"], "thirdparty", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre($arrayfields['contact']['label'], $_SERVER["PHP_SELF"], "contact", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre($arrayfields['type']['label'], $_SERVER["PHP_SELF"], "type", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre($arrayfields['status']['label'], $_SERVER["PHP_SELF"], "statut", "", $param, "", $sortfield, $sortorder); +print_liste_field_titre($arrayfields['link']['label'], $_SERVER["PHP_SELF"], "", "", "", "", $sortfield, $sortorder, 'center maxwidthsearch '); +print ""; + +foreach($list as $entry) +{ + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + + if ($permission) + { + $href = $_SERVER["PHP_SELF"]; + $href .= "?id=".$object->id; + $href .= "&action=deletecontact"; + $href .= "&lineid=".$entry->id; + + print ""; + } + + print ""; +} + +print "
'.$entry->nature.''.$entry->thirdparty.''.$entry->contact.''.$entry->type.''.$entry->status.'"; + print ""; + print img_picto($langs->trans("Unlink"), "unlink"); + print ""; + print "
"; +print ""; +print "
"; +print ""; + print "\n"; if (is_object($hookmanager)) { $hookmanager->initHooks(array('contacttpl')); @@ -248,3 +334,37 @@ if (is_object($hookmanager)) { $reshook=$hookmanager->executeHooks('formContactTpl', $parameters, $object, $action); } print "\n"; + + +// TODO: Remove this functions after switch to $db->sort($sortfield, $sortorder); +function nature_asc($left, $right) +{ + return $left->nature > $right->nature; } +function thirdparty_asc($left, $right) +{ + return $left->thirdparty > $right->thirdparty; } +function contact_asc($left, $right) +{ + return $left->contact > $right->contact; } +function type_asc($left, $right) +{ + return $left->type > $right->type; } +function status_asc($left, $right) +{ + return $left->status > $right->status; } + +function nature_desc($left, $right) +{ + return $left->nature < $right->nature; } +function thirdparty_desc($left, $right) +{ + return $left->thirdparty < $right->thirdparty; } +function contact_desc($left, $right) +{ + return $left->contact < $right->contact; } +function type_desc($left, $right) +{ + return $left->type < $right->type; } +function status_desc($left, $right) +{ + return $left->status < $right->status; } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index f82f91986a0..1ae4364a77d 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -36,6 +36,35 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; */ class Fichinter extends CommonObject { + + public $fields=array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), + 'fk_soc' =>array('type'=>'integer:Societe:societe/class/societe.class.php', 'label'=>'ThirdParty', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>15), + 'fk_projet' =>array('type'=>'integer:Project:projet/class/project.class.php:1:fk_statut=1', 'label'=>'Fk projet', 'enabled'=>1, 'visible'=>-1, 'position'=>20), + 'fk_contrat' =>array('type'=>'integer', 'label'=>'Fk contrat', 'enabled'=>1, 'visible'=>-1, 'position'=>25), + 'ref' =>array('type'=>'varchar(30)', 'label'=>'Ref', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'showoncombobox'=>1, 'position'=>30), + 'ref_ext' =>array('type'=>'varchar(255)', 'label'=>'Ref ext', 'enabled'=>1, 'visible'=>0, 'position'=>35), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>40, 'index'=>1), + 'tms' =>array('type'=>'timestamp', 'label'=>'DateModification', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>45), + 'datec' =>array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>1, 'visible'=>-1, 'position'=>50), + 'date_valid' =>array('type'=>'datetime', 'label'=>'DateValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>55), + 'datei' =>array('type'=>'date', 'label'=>'Datei', 'enabled'=>1, 'visible'=>-1, 'position'=>60), + 'fk_user_author' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'Fk user author', 'enabled'=>1, 'visible'=>-1, 'position'=>65), + 'fk_user_modif' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserModif', 'enabled'=>1, 'visible'=>-2, 'notnull'=>-1, 'position'=>70), + 'fk_user_valid' =>array('type'=>'integer:User:user/class/user.class.php', 'label'=>'UserValidation', 'enabled'=>1, 'visible'=>-1, 'position'=>75), + 'fk_statut' =>array('type'=>'smallint(6)', 'label'=>'Fk statut', 'enabled'=>1, 'visible'=>-1, 'position'=>500), + 'dateo' =>array('type'=>'date', 'label'=>'Dateo', 'enabled'=>1, 'visible'=>-1, 'position'=>85), + 'datee' =>array('type'=>'date', 'label'=>'Datee', 'enabled'=>1, 'visible'=>-1, 'position'=>90), + 'datet' =>array('type'=>'date', 'label'=>'Datet', 'enabled'=>1, 'visible'=>-1, 'position'=>95), + 'duree' =>array('type'=>'double', 'label'=>'Duree', 'enabled'=>1, 'visible'=>-1, 'position'=>100), + 'description' =>array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>105,'showoncombobox'=>1), + 'note_private' =>array('type'=>'text', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>110), + 'note_public' =>array('type'=>'text', 'label'=>'NotePrivate', 'enabled'=>1, 'visible'=>0, 'position'=>115), + 'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>1, 'visible'=>0, 'position'=>120), + 'last_main_doc' =>array('type'=>'varchar(255)', 'label'=>'Last main doc', 'enabled'=>1, 'visible'=>-1, 'position'=>125), + 'import_key' =>array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>130), + 'extraparams' =>array('type'=>'varchar(255)', 'label'=>'Extraparams', 'enabled'=>1, 'visible'=>-1, 'position'=>135), + ); /** * @var string ID to identify managed object */ diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index d8d113941db..94e440f9ab9 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -257,10 +257,11 @@ InvoiceGeneratedFromTimeSpent=Invoice %s has been generated from time spent on p ProjectBillTimeDescription=Check if you enter timesheet on tasks of project AND you plan to generate invoice(s) from the timesheet to bill the customer of the project (do not check if you plan to create invoice that is not based on entered timesheets). Note: To generate invoice, go on tab 'Time spent' of the project and select lines to include. ProjectFollowOpportunity=Follow opportunity ProjectFollowTasks=Follow tasks +Usage=Usage UsageOpportunity=Usage: Opportunity UsageTasks=Usage: Tasks UsageBillTimeShort=Usage: Bill time InvoiceToUse=Draft invoice to use NewInvoice=New invoice OneLinePerTask=One line per task -OneLinePerPeriod=One line per period \ No newline at end of file +OneLinePerPeriod=One line per period