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) { if (empty($conf->global->MAIN_FEATURES_LEVEL) || $conf->global->MAIN_FEATURES_LEVEL < 2) {
return array( return array(
0 => 'Home', 0 => 'Home',
3 => 'thirdpartiesindex',
27 => 'AccountancyHome' 27 => 'AccountancyHome'
); );
} else { } else {

View File

@ -29,6 +29,7 @@
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.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); $hookmanager = new HookManager($db);
@ -47,6 +48,25 @@ $result = restrictedArea($user, 'societe', 0, '', '', '', '');
$thirdparty_static = new Societe($db); $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 * View
@ -56,11 +76,8 @@ $transAreaType = $langs->trans("ThirdPartiesArea");
$helpurl = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:M&oacute;dulo_Terceros'; $helpurl = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:M&oacute;dulo_Terceros';
llxHeader("", $langs->trans("ThirdParties"), $helpurl); llxHeader("", $langs->trans("ThirdParties"), $helpurl);
$linkback = '';
print load_fiche_titre($transAreaType, $linkback, 'companies');
print load_fiche_titre($transAreaType, $resultboxes['selectboxlist'], 'companies');
print '<div class="fichecenter"><div class="fichethirdleft">';
/* /*
@ -115,11 +132,11 @@ if ($result) {
dol_print_error($db); dol_print_error($db);
} }
print '<div class="div-table-responsive-no-min">'; $thirdpartygraph = '<div class="div-table-responsive-no-min">';
print '<table class="noborder nohover centpercent">'."\n"; $thirdpartygraph .= '<table class="noborder nohover centpercent">'."\n";
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>'; $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)) { 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(); $dataseries = array();
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) { 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'])); $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->SetType(array('pie'));
$dolgraph->setHeight('200'); $dolgraph->setHeight('200');
$dolgraph->draw('idgraphthirdparties'); $dolgraph->draw('idgraphthirdparties');
print $dolgraph->show(); $thirdpartygraph .= $dolgraph->show();
print '</td></tr>'."\n"; $thirdpartygraph .= '</td></tr>'."\n";
} else { } else {
if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) { if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) {
$statstring = "<tr>"; $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 .= '<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>"; $statstring2 .= "</tr>";
} }
print $statstring; $thirdpartygraph .= $statstring;
print $statstring2; $thirdpartygraph .= $statstring2;
} }
print '<tr class="liste_total"><td>'.$langs->trans("UniqueThirdParties").'</td><td class="right">'; $thirdpartygraph .= '<tr class="liste_total"><td>'.$langs->trans("UniqueThirdParties").'</td><td class="right">';
print $total; $thirdpartygraph .= $total;
print '</td></tr>'; $thirdpartygraph .= '</td></tr>';
print '</table>'; $thirdpartygraph .= '</table>';
print '</div>'; $thirdpartygraph .= '</div>';
if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) { if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) {
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
$elementtype = 'societe'; $elementtype = 'societe';
print '<br>'; $thirdpartycateggraph .= '<div class="div-table-responsive-no-min">';
$thirdpartycateggraph .= '<table class="noborder nohover centpercent">';
print '<div class="div-table-responsive-no-min">'; $thirdpartycateggraph .= '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Categories").'</th></tr>';
print '<table class="noborder nohover centpercent">'; $thirdpartycateggraph .= '<tr><td class="center" colspan="2">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Categories").'</th></tr>';
print '<tr><td class="center" colspan="2">';
$sql = "SELECT c.label, count(*) as nb"; $sql = "SELECT c.label, count(*) as nb";
$sql .= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs"; $sql .= " FROM ".MAIN_DB_PREFIX."categorie_societe as cs";
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON cs.fk_categorie = c.rowid"; $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->SetType(array('pie'));
$dolgraph->setHeight('200'); $dolgraph->setHeight('200');
$dolgraph->draw('idgraphcateg'); $dolgraph->draw('idgraphcateg');
print $dolgraph->show(); $thirdpartycateggraph .= $dolgraph->show();
} else { } else {
while ($i < $num) { while ($i < $num) {
$obj = $db->fetch_object($result); $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; $total += $obj->nb;
$i++; $i++;
} }
} }
} }
print '</td></tr>'; $thirdpartycateggraph .= '</td></tr>';
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">'; $thirdpartycateggraph .= '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">';
print $total; $thirdpartycateggraph .= $total;
print '</td></tr>'; $thirdpartycateggraph .= '</td></tr>';
print '</table>'; $thirdpartycateggraph .= '</table>';
print '</div>'; $thirdpartycateggraph .= '</div>';
} }
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
/* /*
* Latest modified third parties * Latest modified third parties
@ -279,14 +292,14 @@ if ($result) {
if ($num > 0) { if ($num > 0) {
$transRecordedType = $langs->trans("LastModifiedThirdParties", $max); $transRecordedType = $langs->trans("LastModifiedThirdParties", $max);
print "\n<!-- last thirdparties modified -->\n"; $lastmodified = "\n<!-- last thirdparties modified -->\n";
print '<div class="div-table-responsive-no-min">'; $lastmodified .= '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">'; $lastmodified .= '<table class="noborder centpercent">';
print '<tr class="liste_titre"><th colspan="2">'.$transRecordedType.'</th>'; $lastmodified .= '<tr class="liste_titre"><th colspan="2">'.$transRecordedType.'</th>';
print '<th>&nbsp;</th>'; $lastmodified .= '<th>&nbsp;</th>';
print '<th class="right"><a href="'.DOL_URL_ROOT.'/societe/list.php?sortfield=s.tms&sortorder=DESC">'.$langs->trans("FullList").'</th>'; $lastmodified .= '<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>'."\n";
while ($i < $num) { while ($i < $num) {
$objp = $db->fetch_object($result); $objp = $db->fetch_object($result);
@ -306,37 +319,63 @@ if ($result) {
$thirdparty_static->code_compta_fournisseur = $objp->code_compta_fournisseur; $thirdparty_static->code_compta_fournisseur = $objp->code_compta_fournisseur;
$thirdparty_static->code_compta = $objp->code_compta; $thirdparty_static->code_compta = $objp->code_compta;
print '<tr class="oddeven">'; $lastmodified .= '<tr class="oddeven">';
// Name // Name
print '<td class="nowrap tdoverflowmax200">'; $lastmodified .= '<td class="nowrap tdoverflowmax200">';
print $thirdparty_static->getNomUrl(1); $lastmodified .= $thirdparty_static->getNomUrl(1);
print "</td>\n"; $lastmodified .= "</td>\n";
// Type // Type
print '<td class="center">'; $lastmodified .= '<td class="center">';
print $thirdparty_static->getTypeUrl(); $lastmodified .= $thirdparty_static->getTypeUrl();
print '</td>'; $lastmodified .= '</td>';
// Last modified date // Last modified date
print '<td class="right tddate">'; $lastmodified .= '<td class="right tddate">';
print dol_print_date($thirdparty_static->date_modification, 'day'); $lastmodified .= dol_print_date($thirdparty_static->date_modification, 'day');
print "</td>"; $lastmodified .= "</td>";
print '<td class="right nowrap">'; $lastmodified .= '<td class="right nowrap">';
print $thirdparty_static->getLibStatut(3); $lastmodified .= $thirdparty_static->getLibStatut(3);
print "</td>"; $lastmodified .= "</td>";
print "</tr>\n"; $lastmodified .= "</tr>\n";
$i++; $i++;
} }
$db->free($result); $db->free($result);
print "</table>\n"; $lastmodified .= "</table>\n";
print '</div>'; $lastmodified .= '</div>';
print "<!-- End last thirdparties modified -->\n"; $lastmodified .= "<!-- End last thirdparties modified -->\n";
} }
} else { } else {
dol_print_error($db); 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); $parameters = array('user' => $user);
$reshook = $hookmanager->executeHooks('dashboardThirdparties', $parameters, $object); // Note that $action and $object may have been modified by hook $reshook = $hookmanager->executeHooks('dashboardThirdparties', $parameters, $object); // Note that $action and $object may have been modified by hook