30 require
'../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
36 $hookmanager->initHooks(array(
'thirdpartiesindex'));
38 $langs->load(
"companies");
40 $socid =
GETPOST(
'socid',
'int');
41 if ($user->socid) $socid = $user->socid;
46 $thirdparty_static =
new Societe($db);
53 $transAreaType = $langs->trans(
"ThirdPartiesArea");
54 $helpurl =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Terceros';
56 llxHeader(
"", $langs->trans(
"ThirdParties"), $helpurl);
61 print '<div class="fichecenter"><div class="fichethirdleft">';
76 $sql =
"SELECT s.rowid, s.client, s.fournisseur";
77 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
78 if (!$user->rights->societe->client->voir && !$socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
79 $sql .=
' WHERE s.entity IN ('.getEntity(
'societe').
')';
80 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
81 if ($socid) $sql .=
" AND s.rowid = ".$socid;
82 if (!$user->rights->fournisseur->lire) $sql .=
" AND (s.fournisseur <> 1 OR s.client <> 0)";
84 $result = $db->query($sql);
87 while ($objp = $db->fetch_object($result))
90 if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) { $found = 1; $third[
'prospect']++; }
91 if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) { $found = 1; $third[
'customer']++; }
92 if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) { $found = 1; $third[
'supplier']++; }
93 if (!empty($conf->societe->enabled) && $objp->client == 0 && $objp->fournisseur == 0) { $found = 1; $third[
'other']++; }
98 print '<div class="div-table-responsive-no-min">';
99 print '<table class="noborder nohover centpercent">'.
"\n";
100 print '<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
'</th></tr>';
101 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))
103 print '<tr><td class="center" colspan="2">';
104 $dataseries = array();
105 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']));
106 if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) $dataseries[] = array($langs->trans(
"Customers"), round($third[
'customer']));
107 if (!empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) $dataseries[] = array($langs->trans(
"Suppliers"), round($third[
'supplier']));
108 if (!empty($conf->societe->enabled)) $dataseries[] = array($langs->trans(
"Others"), round($third[
'other']));
109 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
111 $dolgraph->SetData($dataseries);
112 $dolgraph->setShowLegend(2);
113 $dolgraph->setShowPercent(1);
114 $dolgraph->SetType(array(
'pie'));
115 $dolgraph->setHeight(
'200');
116 $dolgraph->draw(
'idgraphthirdparties');
117 print $dolgraph->show();
118 print '</td></tr>'.
"\n";
120 if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS))
122 $statstring =
"<tr>";
123 $statstring .=
'<td><a href="'.DOL_URL_ROOT.
'/societe/list.php?type=p">'.$langs->trans(
"Prospects").
'</a></td><td class="right">'.round($third[
'prospect']).
'</td>';
124 $statstring .=
"</tr>";
126 if (!empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS))
128 $statstring .=
"<tr>";
129 $statstring .=
'<td><a href="'.DOL_URL_ROOT.
'/societe/list.php?type=c">'.$langs->trans(
"Customers").
'</a></td><td class="right">'.round($third[
'customer']).
'</td>';
130 $statstring .=
"</tr>";
132 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $user->rights->fournisseur->lire)
134 $statstring2 =
"<tr>";
135 $statstring2 .=
'<td><a href="'.DOL_URL_ROOT.
'/societe/list.php?type=f">'.$langs->trans(
"Suppliers").
'</a></td><td class="right">'.round($third[
'supplier']).
'</td>';
136 $statstring2 .=
"</tr>";
141 print '<tr class="liste_total"><td>'.$langs->trans(
"UniqueThirdParties").
'</td><td class="right">';
147 if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES))
149 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
150 $elementtype =
'societe';
154 print '<div class="div-table-responsive-no-min">';
155 print '<table class="noborder nohover centpercent">';
156 print '<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Categories").
'</th></tr>';
157 print '<tr><td class="center" colspan="2">';
158 $sql =
"SELECT c.label, count(*) as nb";
159 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie_societe as cs";
160 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"categorie as c ON cs.fk_categorie = c.rowid";
161 $sql .=
" WHERE c.type = 2";
162 if (!is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) $sql .=
" AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES).
"'";
163 $sql .=
" AND c.entity IN (".getEntity(
'category').
")";
164 $sql .=
" GROUP BY c.label";
166 $result = $db->query($sql);
169 $num = $db->num_rows($result);
171 if (!empty($conf->use_javascript_ajax))
173 $dataseries = array();
179 $obj = $db->fetch_object($result);
182 $dataseries[] = array($obj->label, round($obj->nb));
191 $dataseries[] = array($langs->trans(
"Other"), round($rest));
193 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
195 $dolgraph->SetData($dataseries);
196 $dolgraph->setShowLegend(2);
197 $dolgraph->setShowPercent(1);
198 $dolgraph->SetType(array(
'pie'));
199 $dolgraph->setHeight(
'200');
200 $dolgraph->draw(
'idgraphcateg');
201 print $dolgraph->show();
205 $obj = $db->fetch_object($result);
207 print '<tr class="oddeven"><td>'.$obj->label.
'</td><td>'.$obj->nb.
'</td></tr>';
214 print '<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">';
221 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
228 $sql =
"SELECT s.rowid, s.nom as name, s.email, s.client, s.fournisseur";
229 $sql .=
", s.code_client";
230 $sql .=
", s.code_fournisseur";
231 $sql .=
", s.code_compta_fournisseur";
232 $sql .=
", s.code_compta";
234 $sql .=
", s.entity";
235 $sql .=
", s.canvas, s.tms as date_modification, s.status as status";
236 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
237 if (!$user->rights->societe->client->voir && !$socid) $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
238 $sql .=
' WHERE s.entity IN ('.getEntity(
'societe').
')';
239 if (!$user->rights->societe->client->voir && !$socid) $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
240 if ($socid) $sql .=
" AND s.rowid = ".$socid;
241 if (!$user->rights->fournisseur->lire) $sql .=
" AND (s.fournisseur != 1 OR s.client != 0)";
242 $sql .= $db->order(
"s.tms",
"DESC");
243 $sql .= $db->plimit($max, 0);
246 $result = $db->query($sql);
249 $num = $db->num_rows($result);
255 $transRecordedType = $langs->trans(
"LastModifiedThirdParties", $max);
257 print "\n<!-- last thirdparties modified -->\n";
258 print '<div class="div-table-responsive-no-min">';
259 print '<table class="noborder centpercent">';
261 print '<tr class="liste_titre"><th colspan="2">'.$transRecordedType.
'</th>';
262 print '<th> </th>';
263 print '<th class="right"><a href="'.DOL_URL_ROOT.
'/societe/list.php?sortfield=s.tms&sortorder=DESC">'.$langs->trans(
"FullList").
'</th>';
268 $objp = $db->fetch_object($result);
270 $thirdparty_static->id = $objp->rowid;
271 $thirdparty_static->name = $objp->name;
272 $thirdparty_static->client = $objp->client;
273 $thirdparty_static->fournisseur = $objp->fournisseur;
274 $thirdparty_static->logo = $objp->logo;
275 $thirdparty_static->date_modification = $db->jdate($objp->date_modification);
276 $thirdparty_static->status = $objp->status;
277 $thirdparty_static->code_client = $objp->code_client;
278 $thirdparty_static->code_fournisseur = $objp->code_fournisseur;
279 $thirdparty_static->canvas = $objp->canvas;
280 $thirdparty_static->email = $objp->email;
281 $thirdparty_static->entity = $objp->entity;
282 $thirdparty_static->code_compta_fournisseur = $objp->code_compta_fournisseur;
283 $thirdparty_static->code_compta = $objp->code_compta;
285 print '<tr class="oddeven">';
287 print '<td class="nowrap tdoverflowmax200">';
288 print $thirdparty_static->getNomUrl(1);
291 print '<td class="center">';
292 $obj = $thirdparty_static;
294 if (($obj->client == 2 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS))
296 $s .=
'<a class="customer-back opacitymedium" title="'.$langs->trans(
"Prospect").
'" href="'.DOL_URL_ROOT.
'/comm/card.php?socid='.$thirdparty_static->id.
'">'.
dol_substr($langs->trans(
"Prospect"), 0, 1).
'</a>';
298 if (($obj->client == 1 || $obj->client == 3) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS))
300 $s .=
'<a class="customer-back" title="'.$langs->trans(
"Customer").
'" href="'.DOL_URL_ROOT.
'/comm/card.php?socid='.$thirdparty_static->id.
'">'.
dol_substr($langs->trans(
"Customer"), 0, 1).
'</a>';
302 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled)) && $obj->fournisseur)
304 $s .=
'<a class="vendor-back" title="'.$langs->trans(
"Supplier").
'" href="'.DOL_URL_ROOT.
'/fourn/card.php?socid='.$thirdparty_static->id.
'">'.
dol_substr($langs->trans(
"Supplier"), 0, 1).
'</a>';
309 print '<td class="right tddate">';
312 print '<td class="right nowrap">';
313 print $thirdparty_static->getLibStatut(3);
323 print "<!-- End last thirdparties modified -->\n";
329 print '</div></div></div>';
331 $parameters = array(
'user' => $user);
332 $reshook = $hookmanager->executeHooks(
'dashboardThirdparties', $parameters, $object);
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_substr($string, $start, $length, $stringencoding= '', $trunconbytes=0)
Make a substring.
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...