can add box on thirparties index

This commit is contained in:
Frédéric FRANCE 2021-03-06 16:38:07 +01:00
parent 63aa2f4ec2
commit 92754760f4
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
2 changed files with 98 additions and 58 deletions

View File

@ -40,6 +40,7 @@ class InfoBox
if (empty($conf->global->MAIN_FEATURES_LEVEL) || $conf->global->MAIN_FEATURES_LEVEL < 2) {
return array(
0 => 'Home',
3 => 'thirdpartiesindex',
27 => 'AccountancyHome'
);
} else {

View File

@ -29,6 +29,7 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
$hookmanager = new HookManager($db);
@ -47,6 +48,25 @@ $result = restrictedArea($user, 'societe', 0, '', '', '', '');
$thirdparty_static = new Societe($db);
if (!isset($form) || !is_object($form)) {
$form = new Form($db);
}
// Load $resultboxes
$resultboxes = FormOther::getBoxesArea($user, "3");
if (GETPOST('addbox')) {
// Add box (when submit is done from a form when ajax disabled)
require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
$zone = GETPOST('areacode', 'aZ09');
$userid = GETPOST('userid', 'int');
$boxorder = GETPOST('boxorder', 'aZ09');
$boxorder .= GETPOST('boxcombo', 'aZ09');
$result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
if ($result > 0) {
setEventMessages($langs->trans("BoxAdded"), null);
}
}
/*
* View
@ -56,11 +76,8 @@ $transAreaType = $langs->trans("ThirdPartiesArea");
$helpurl = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:M&oacute;dulo_Terceros';
llxHeader("", $langs->trans("ThirdParties"), $helpurl);
$linkback = '';
print load_fiche_titre($transAreaType, $linkback, 'companies');
print '<div class="fichecenter"><div class="fichethirdleft">';
print load_fiche_titre($transAreaType, $resultboxes['selectboxlist'], 'companies');
/*
@ -115,11 +132,11 @@ if ($result) {
dol_print_error($db);
}
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder nohover centpercent">'."\n";
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
$thirdpartygraph = '<div class="div-table-responsive-no-min">';
$thirdpartygraph .= '<table class="noborder nohover centpercent">'."\n";
$thirdpartygraph .= '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) + (round($third['customer']) ? 1 : 0) + (round($third['supplier']) ? 1 : 0) + (round($third['other']) ? 1 : 0) >= 2)) {
print '<tr><td class="center" colspan="2">';
$thirdpartygraph .= '<tr><td class="center" colspan="2">';
$dataseries = array();
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) {
$dataseries[] = array($langs->trans("Prospects"), round($third['prospect']));
@ -141,8 +158,8 @@ if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) +
$dolgraph->SetType(array('pie'));
$dolgraph->setHeight('200');
$dolgraph->draw('idgraphthirdparties');
print $dolgraph->show();
print '</td></tr>'."\n";
$thirdpartygraph .= $dolgraph->show();
$thirdpartygraph .= '</td></tr>'."\n";
} else {
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) {
$statstring = "<tr>";
@ -159,25 +176,23 @@ if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) +
$statstring2 .= '<td><a href="'.DOL_URL_ROOT.'/societe/list.php?type=f">'.$langs->trans("Suppliers").'</a></td><td class="right">'.round($third['supplier']).'</td>';
$statstring2 .= "</tr>";
}
print $statstring;
print $statstring2;
$thirdpartygraph .= $statstring;
$thirdpartygraph .= $statstring2;
}
print '<tr class="liste_total"><td>'.$langs->trans("UniqueThirdParties").'</td><td class="right">';
print $total;
print '</td></tr>';
print '</table>';
print '</div>';
$thirdpartygraph .= '<tr class="liste_total"><td>'.$langs->trans("UniqueThirdParties").'</td><td class="right">';
$thirdpartygraph .= $total;
$thirdpartygraph .= '</td></tr>';
$thirdpartygraph .= '</table>';
$thirdpartygraph .= '</div>';
if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$elementtype = 'societe';
print '<br>';
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder nohover centpercent">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Categories").'</th></tr>';
print '<tr><td class="center" colspan="2">';
$thirdpartycateggraph .= '<div class="div-table-responsive-no-min">';
$thirdpartycateggraph .= '<table class="noborder nohover centpercent">';
$thirdpartycateggraph .= '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Categories").'</th></tr>';
$thirdpartycateggraph .= '<tr><td class="center" colspan="2">';
$sql = "SELECT c.label, count(*) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid";
@ -218,27 +233,25 @@ if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTA
$dolgraph->SetType(array('pie'));
$dolgraph->setHeight('200');
$dolgraph->draw('idgraphcateg');
print $dolgraph->show();
$thirdpartycateggraph .= $dolgraph->show();
} else {
while ($i < $num) {
$obj = $db->fetch_object($result);
print '<tr class="oddeven"><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>';
$thirdpartycateggraph .= '<tr class="oddeven"><td>'.$obj->label.'</td><td>'.$obj->nb.'</td></tr>';
$total += $obj->nb;
$i++;
}
}
}
print '</td></tr>';
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">';
print $total;
print '</td></tr>';
print '</table>';
print '</div>';
$thirdpartycateggraph .= '</td></tr>';
$thirdpartycateggraph .= '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">';
$thirdpartycateggraph .= $total;
$thirdpartycateggraph .= '</td></tr>';
$thirdpartycateggraph .= '</table>';
$thirdpartycateggraph .= '</div>';
}
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
/*
* Latest modified third parties
@ -279,14 +292,14 @@ if ($result) {
if ($num > 0) {
$transRecordedType = $langs->trans("LastModifiedThirdParties", $max);
print "\n<!-- last thirdparties modified -->\n";
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
$lastmodified = "\n<!-- last thirdparties modified -->\n";
$lastmodified .= '<div class="div-table-responsive-no-min">';
$lastmodified .= '<table class="noborder centpercent">';
print '<tr class="liste_titre"><th colspan="2">'.$transRecordedType.'</th>';
print '<th>&nbsp;</th>';
print '<th class="right"><a href="'.DOL_URL_ROOT.'/societe/list.php?sortfield=s.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
print '</tr>'."\n";
$lastmodified .= '<tr class="liste_titre"><th colspan="2">'.$transRecordedType.'</th>';
$lastmodified .= '<th>&nbsp;</th>';
$lastmodified .= '<th class="right"><a href="'.DOL_URL_ROOT.'/societe/list.php?sortfield=s.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>';
$lastmodified .= '</tr>'."\n";
while ($i < $num) {
$objp = $db->fetch_object($result);
@ -306,37 +319,63 @@ if ($result) {
$thirdparty_static->code_compta_fournisseur = $objp->code_compta_fournisseur;
$thirdparty_static->code_compta = $objp->code_compta;
print '<tr class="oddeven">';
$lastmodified .= '<tr class="oddeven">';
// Name
print '<td class="nowrap tdoverflowmax200">';
print $thirdparty_static->getNomUrl(1);
print "</td>\n";
$lastmodified .= '<td class="nowrap tdoverflowmax200">';
$lastmodified .= $thirdparty_static->getNomUrl(1);
$lastmodified .= "</td>\n";
// Type
print '<td class="center">';
print $thirdparty_static->getTypeUrl();
print '</td>';
$lastmodified .= '<td class="center">';
$lastmodified .= $thirdparty_static->getTypeUrl();
$lastmodified .= '</td>';
// Last modified date
print '<td class="right tddate">';
print dol_print_date($thirdparty_static->date_modification, 'day');
print "</td>";
print '<td class="right nowrap">';
print $thirdparty_static->getLibStatut(3);
print "</td>";
print "</tr>\n";
$lastmodified .= '<td class="right tddate">';
$lastmodified .= dol_print_date($thirdparty_static->date_modification, 'day');
$lastmodified .= "</td>";
$lastmodified .= '<td class="right nowrap">';
$lastmodified .= $thirdparty_static->getLibStatut(3);
$lastmodified .= "</td>";
$lastmodified .= "</tr>\n";
$i++;
}
$db->free($result);
print "</table>\n";
print '</div>';
print "<!-- End last thirdparties modified -->\n";
$lastmodified .= "</table>\n";
$lastmodified .= '</div>';
$lastmodified .= "<!-- End last thirdparties modified -->\n";
}
} else {
dol_print_error($db);
}
print '</div></div></div>';
//print '</div></div></div>';
// boxes
print '<div class="clearboth"></div>';
print '<div class="fichecenter fichecenterbis">';
$boxlist = '<div class="twocolumns">';
$boxlist .= '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
$boxlist .= $thirdpartygraph;
$boxlist .= '<br>';
$boxlist .= $thirdpartycateggraph;
$boxlist .= '<br>';
$boxlist .= $resultboxes['boxlista'];
$boxlist .= '</div>'."\n";
$boxlist .= '<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
$boxlist .= $lastmodified;
$boxlist .= '<br>';
$boxlist .= $resultboxes['boxlistb'];
$boxlist .= '</div>'."\n";
$boxlist .= '</div>';
print $boxlist;
print '</div>';
$parameters = array('user' => $user);
$reshook = $hookmanager->executeHooks('dashboardThirdparties', $parameters, $object); // Note that $action and $object may have been modified by hook