Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2020-03-04 19:28:24 +01:00
commit 0766097658
3 changed files with 210 additions and 60 deletions

View File

@ -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);
<div class="tagtable tableforcontact centpercent noborder nobordertop allwidth">
<?php
if ($permission) {
?>
if ($permission)
{
?>
<form class="tagtr liste_titre">
<div class="tagtd liste_titre"><?php echo $langs->trans("NatureOfContact"); ?></div>
<div class="tagtd liste_titre"><?php echo $langs->trans("ThirdParty"); ?></div>
@ -153,94 +153,180 @@ if ($permission) {
<?php
}
}
?>
<form class="tagtr liste_titre liste_titre_add formnoborder">
<div class="tagtd liste_titre"><?php echo $langs->trans("NatureOfContact"); ?></div>
<div class="tagtd liste_titre"><?php echo $langs->trans("ThirdParty"); ?></div>
<div class="tagtd liste_titre"><?php echo $langs->trans("Users").'/'.$langs->trans("Contacts"); ?></div>
<div class="tagtd liste_titre"><?php echo $langs->trans("ContactType"); ?></div>
<div class="tagtd liste_titre center"><?php echo $langs->trans("Status"); ?></div>
<div class="tagtd liste_titre">&nbsp;</div>
</form>
print "</div>";
<?php
$arrayofsource=array('internal','external'); // Show both link to user and thirdparties contacts
foreach($arrayofsource as $source) {
$tmpobject=$object;
if (($object->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");
}
<form class="tagtr oddeven">
<div class="tagtd left">
<?php if ($tab[$i]['source']=='internal') echo $langs->trans("User"); ?>
<?php if ($tab[$i]['source']=='external') echo $langs->trans("ThirdPartyContact"); ?>
</div>
<div class="tagtd left">
<?php
if ($tab[$i]['socid'] > 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 '&nbsp;';
$entry->thirdparty = "";
}
?>
</div>
<div class="tagtd">
<?php
$statusofcontact = $tab[$i]['status'];
if ($tab[$i]['source']=='internal')
{
$userstatic->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);
}
?>
</div>
<div class="tagtd"><?php echo $tab[$i]['libelle']; ?></div>
<div class="tagtd center">
<?php //if ($object->statut >= 0) echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=swapstatut&amp;ligne='.$tab[$i]['rowid'].'">';
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 '</a>'; ?>
</div>
<div class="tagtd nowrap right">
<?php if ($permission) { ?>
&nbsp;<a href="<?php echo $_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=deletecontact&amp;lineid='.$tab[$i]['rowid']; ?>"><?php echo img_picto($langs->trans('Unlink'), 'unlink'); ?></a>
<?php } ?>
</div>
</form>
<?php $i++;
$i++;
$list[] = $entry;
}
}
print "</div>\n";
print "</div>\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 '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
print '<input type="hidden" name="action" value="list">';
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
print '<table class="tagtable nobottomiftotal liste">';
print '<tr class="liste_titre_filter">';
print '</tr>';
print '<tr class="liste_titre">';
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 "</tr>";
foreach($list as $entry)
{
print '<tr class="oddeven">';
print '<td class="nowrap">'.$entry->nature.'</td>';
print '<td class="tdoverflowmax200">'.$entry->thirdparty.'</td>';
print '<td class="tdoverflowmax200">'.$entry->contact.'</td>';
print '<td class="tdoverflowmax200">'.$entry->type.'</td>';
print '<td class="tdoverflowmax200">'.$entry->status.'</td>';
if ($permission)
{
$href = $_SERVER["PHP_SELF"];
$href .= "?id=".$object->id;
$href .= "&action=deletecontact";
$href .= "&lineid=".$entry->id;
print "<td class='center'>";
print "<a href='$href'>";
print img_picto($langs->trans("Unlink"), "unlink");
print "</a>";
print "</td>";
}
print "</tr>";
}
print "</table>";
print "</div>";
print "</form>";
print "</div>";
print "<!-- TEMPLATE CONTACTS HOOK BEGIN HERE -->\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 "<!-- END PHP TEMPLATE CONTACTS -->\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; }

View File

@ -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
*/

View File

@ -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
OneLinePerPeriod=One line per period