31require
'../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
37$langs->load(
"companies");
42$hookmanager->initHooks(array(
'thirdpartiesindex'));
46$socid =
GETPOST(
'socid',
'int');
48 $socid = $user->socid;
54$thirdparty_static =
new Societe($db);
56if (!isset($form) || !is_object($form)) {
57 $form =
new Form($db);
65 require_once DOL_DOCUMENT_ROOT.
'/core/class/infobox.class.php';
66 $zone =
GETPOST(
'areacode',
'int');
67 $userid =
GETPOST(
'userid',
'int');
68 $boxorder =
GETPOST(
'boxorder',
'aZ09');
69 $boxorder .=
GETPOST(
'boxcombo',
'aZ09');
81$transAreaType = $langs->trans(
"ThirdPartiesArea");
82$helpurl =
'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Terceros';
84llxHeader(
"", $langs->trans(
"ThirdParties"), $helpurl);
86print
load_fiche_titre($transAreaType, $resultboxes[
'selectboxlist'],
'companies');
101$sql =
"SELECT s.rowid, s.client, s.fournisseur";
102$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
103if (empty($user->rights->societe->client->voir) && !$socid) {
104 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
106$sql .=
' WHERE s.entity IN ('.getEntity(
'societe').
')';
107if (empty($user->rights->societe->client->voir) && !$socid) {
108 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
110if (empty($user->rights->fournisseur->lire)) {
111 $sql .=
" AND (s.fournisseur <> 1 OR s.client <> 0)";
114$parameters = array(
'socid' => $socid);
115$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $thirdparty_static);
116if (empty($reshook)) {
118 $sql .=
" AND s.rowid = ".((int) $socid);
121$sql .= $hookmanager->resPrint;
123$result = $db->query($sql);
125 while ($objp = $db->fetch_object($result)) {
127 if (isModEnabled(
'societe') && $user->hasRight(
'societe',
'lire') && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS) && ($objp->client == 2 || $objp->client == 3)) {
128 $found = 1; $third[
'prospect']++;
130 if (isModEnabled(
'societe') && $user->hasRight(
'societe',
'lire') && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS) && ($objp->client == 1 || $objp->client == 3)) {
131 $found = 1; $third[
'customer']++;
133 if (((isModEnabled(
'fournisseur') && $user->hasRight(
'fournisseur',
'facture',
'lire') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled(
'supplier_order') && $user->hasRight(
'supplier_order',
'lire')) || (isModEnabled(
'supplier_invoice') && $user->hasRight(
'supplier_invoice',
'lire'))) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS) && $objp->fournisseur) {
134 $found = 1; $third[
'supplier']++;
136 if (isModEnabled(
'societe') && $objp->client == 0 && $objp->fournisseur == 0) {
137 $found = 1; $third[
'other']++;
147$thirdpartygraph =
'<div class="div-table-responsive-no-min">';
148$thirdpartygraph .=
'<table class="noborder nohover centpercent">'.
"\n";
149$thirdpartygraph .=
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
'</th></tr>';
150if (!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)) {
151 $thirdpartygraph .=
'<tr><td class="center" colspan="2">';
152 $dataseries = array();
153 if (isModEnabled(
'societe') && $user->hasRight(
'societe',
'lire') && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) {
154 $dataseries[] = array($langs->transnoentitiesnoconv(
"Prospects"), round($third[
'prospect']));
156 if (isModEnabled(
'societe') && $user->hasRight(
'societe',
'lire') && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) {
157 $dataseries[] = array($langs->transnoentitiesnoconv(
"Customers"), round($third[
'customer']));
159 if (((isModEnabled(
'fournisseur') && $user->hasRight(
'fournisseur',
'facture',
'lire') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled(
'supplier_order') && $user->hasRight(
'supplier_order',
'lire')) || (isModEnabled(
'supplier_invoice') && $user->hasRight(
'supplier_invoice',
'lire'))) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) {
160 $dataseries[] = array($langs->transnoentitiesnoconv(
"Suppliers"), round($third[
'supplier']));
162 if (isModEnabled(
'societe')) {
163 $dataseries[] = array($langs->transnoentitiesnoconv(
"Others"), round($third[
'other']));
165 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
167 $dolgraph->SetData($dataseries);
168 $dolgraph->setShowLegend(2);
169 $dolgraph->setShowPercent(1);
170 $dolgraph->SetType(array(
'pie'));
171 $dolgraph->setHeight(
'200');
172 $dolgraph->draw(
'idgraphthirdparties');
173 $thirdpartygraph .= $dolgraph->show();
174 $thirdpartygraph .=
'</td></tr>'.
"\n";
176 if (isModEnabled(
'societe') && $user->hasRight(
'societe',
'lire') && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS)) {
177 $statstring =
"<tr>";
178 $statstring .=
'<td><a href="'.DOL_URL_ROOT.
'/societe/list.php?type=p">'.$langs->trans(
"Prospects").
'</a></td><td class="right">'.round($third[
'prospect']).
'</td>';
179 $statstring .=
"</tr>";
181 if (isModEnabled(
'societe') && $user->hasRight(
'societe',
'lire') && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS)) {
182 $statstring .=
"<tr>";
183 $statstring .=
'<td><a href="'.DOL_URL_ROOT.
'/societe/list.php?type=c">'.$langs->trans(
"Customers").
'</a></td><td class="right">'.round($third[
'customer']).
'</td>';
184 $statstring .=
"</tr>";
187 if (((isModEnabled(
'fournisseur') && $user->hasRight(
'fournisseur',
'facture',
'lire') && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled(
'supplier_order') && $user->hasRight(
'supplier_order',
'lire')) || (isModEnabled(
'supplier_invoice') && $user->hasRight(
'supplier_invoice',
'lire'))) && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS)) {
188 $statstring2 =
"<tr>";
189 $statstring2 .=
'<td><a href="'.DOL_URL_ROOT.
'/societe/list.php?type=f">'.$langs->trans(
"Suppliers").
'</a></td><td class="right">'.round($third[
'supplier']).
'</td>';
190 $statstring2 .=
"</tr>";
192 $thirdpartygraph .= $statstring;
193 $thirdpartygraph .= $statstring2;
195$thirdpartygraph .=
'<tr class="liste_total"><td>'.$langs->trans(
"UniqueThirdParties").
'</td><td class="right">';
196$thirdpartygraph .= $total;
197$thirdpartygraph .=
'</td></tr>';
198$thirdpartygraph .=
'</table>';
199$thirdpartygraph .=
'</div>';
201$thirdpartycateggraph =
'';
202if (isModEnabled(
'categorie') && !empty($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) {
203 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
204 $elementtype =
'societe';
206 $thirdpartycateggraph =
'<div class="div-table-responsive-no-min">';
207 $thirdpartycateggraph .=
'<table class="noborder nohover centpercent">';
208 $thirdpartycateggraph .=
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Categories").
'</th></tr>';
209 $thirdpartycateggraph .=
'<tr><td class="center" colspan="2">';
210 $sql =
"SELECT c.label, count(*) as nb";
211 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie_societe as cs";
212 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"categorie as c ON cs.fk_categorie = c.rowid";
213 $sql .=
" WHERE c.type = 2";
214 if (!is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) {
215 $sql .=
" AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES).
"'";
217 $sql .=
" AND c.entity IN (".getEntity(
'category').
")";
218 $sql .=
" GROUP BY c.label";
220 $result = $db->query($sql);
222 $num = $db->num_rows($result);
224 if (!empty($conf->use_javascript_ajax)) {
225 $dataseries = array();
230 $obj = $db->fetch_object($result);
232 $dataseries[] = array($obj->label, round($obj->nb));
240 $dataseries[] = array($langs->trans(
"Other"), round($rest));
242 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
244 $dolgraph->SetData($dataseries);
245 $dolgraph->setShowLegend(2);
246 $dolgraph->setShowPercent(1);
247 $dolgraph->SetType(array(
'pie'));
248 $dolgraph->setHeight(
'200');
249 $dolgraph->draw(
'idgraphcateg');
250 $thirdpartycateggraph .= $dolgraph->show();
253 $obj = $db->fetch_object($result);
255 $thirdpartycateggraph .=
'<tr class="oddeven"><td>'.$obj->label.
'</td><td>'.$obj->nb.
'</td></tr>';
261 $thirdpartycateggraph .=
'</td></tr>';
262 $thirdpartycateggraph .=
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">';
263 $thirdpartycateggraph .= $total;
264 $thirdpartycateggraph .=
'</td></tr>';
265 $thirdpartycateggraph .=
'</table>';
266 $thirdpartycateggraph .=
'</div>';
268 $thirdpartycateggraph =
'';
276$sql =
"SELECT s.rowid, s.nom as name, s.email, s.client, s.fournisseur";
277$sql .=
", s.code_client";
278$sql .=
", s.code_fournisseur";
279if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
280 $sql .=
", spe.accountancy_code_supplier as code_compta_fournisseur";
281 $sql .=
", spe.accountancy_code_customer as code_compta";
283 $sql .=
", s.code_compta_fournisseur";
284 $sql .=
", s.code_compta";
288$sql .=
", s.canvas, s.tms as date_modification, s.status as status";
289$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
290if (!empty($conf->global->MAIN_COMPANY_PERENTITY_SHARED)) {
291 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
293if (empty($user->rights->societe->client->voir) && !$socid) {
294 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
296$sql .=
' WHERE s.entity IN ('.getEntity(
'societe').
')';
297if (empty($user->rights->societe->client->voir) && !$socid) {
298 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
300if (empty($user->rights->fournisseur->lire)) {
301 $sql .=
" AND (s.fournisseur != 1 OR s.client != 0)";
304$parameters = array(
'socid' => $socid);
305$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $thirdparty_static);
306if (empty($reshook)) {
308 $sql .=
" AND s.rowid = ".((int) $socid);
311$sql .= $hookmanager->resPrint;
312$sql .= $db->order(
"s.tms",
"DESC");
313$sql .= $db->plimit($max, 0);
317$result = $db->query($sql);
319 $num = $db->num_rows($result);
324 $transRecordedType = $langs->trans(
"LastModifiedThirdParties", $max);
326 $lastmodified =
"\n<!-- last thirdparties modified -->\n";
327 $lastmodified .=
'<div class="div-table-responsive-no-min">';
328 $lastmodified .=
'<table class="noborder centpercent">';
330 $lastmodified .=
'<tr class="liste_titre"><th colspan="2">'.$transRecordedType.
'</th>';
331 $lastmodified .=
'<th> </th>';
332 $lastmodified .=
'<th class="right"><a href="'.DOL_URL_ROOT.
'/societe/list.php?sortfield=s.tms&sortorder=DESC">'.$langs->trans(
"FullList").
'</th>';
333 $lastmodified .=
'</tr>'.
"\n";
336 $objp = $db->fetch_object($result);
338 $thirdparty_static->id = $objp->rowid;
339 $thirdparty_static->name = $objp->name;
340 $thirdparty_static->client = $objp->client;
341 $thirdparty_static->fournisseur = $objp->fournisseur;
342 $thirdparty_static->logo = $objp->logo;
343 $thirdparty_static->date_modification = $db->jdate($objp->date_modification);
344 $thirdparty_static->status = $objp->status;
345 $thirdparty_static->code_client = $objp->code_client;
346 $thirdparty_static->code_fournisseur = $objp->code_fournisseur;
347 $thirdparty_static->canvas = $objp->canvas;
348 $thirdparty_static->email = $objp->email;
349 $thirdparty_static->entity = $objp->entity;
350 $thirdparty_static->code_compta_fournisseur = $objp->code_compta_fournisseur;
351 $thirdparty_static->code_compta = $objp->code_compta;
353 $lastmodified .=
'<tr class="oddeven">';
355 $lastmodified .=
'<td class="nowrap tdoverflowmax200">';
356 $lastmodified .= $thirdparty_static->getNomUrl(1);
357 $lastmodified .=
"</td>\n";
359 $lastmodified .=
'<td class="center">';
360 $lastmodified .= $thirdparty_static->getTypeUrl();
361 $lastmodified .=
'</td>';
363 $lastmodified .=
'<td class="right tddate" title="'.dol_escape_htmltag($langs->trans(
"DateModification").
' '.
dol_print_date($thirdparty_static->date_modification,
'dayhour',
'tzuserrel')).
'">';
364 $lastmodified .=
dol_print_date($thirdparty_static->date_modification,
'day',
'tzuserrel');
365 $lastmodified .=
"</td>";
366 $lastmodified .=
'<td class="right nowrap">';
367 $lastmodified .= $thirdparty_static->getLibStatut(3);
368 $lastmodified .=
"</td>";
369 $lastmodified .=
"</tr>\n";
375 $lastmodified .=
"</table>\n";
376 $lastmodified .=
'</div>';
377 $lastmodified .=
"<!-- End last thirdparties modified -->\n";
386print
'<div class="clearboth"></div>';
387print
'<div class="fichecenter fichecenterbis">';
389$boxlist =
'<div class="twocolumns">';
391$boxlist .=
'<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
392$boxlist .= $thirdpartygraph;
394$boxlist .= $thirdpartycateggraph;
396$boxlist .= $resultboxes[
'boxlista'];
397$boxlist .=
'</div>'.
"\n";
399$boxlist .=
'<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
400$boxlist .= $lastmodified;
402$boxlist .= $resultboxes[
'boxlistb'];
403$boxlist .=
'</div>'.
"\n";
411$parameters = array(
'user' => $user);
412$reshook = $hookmanager->executeHooks(
'dashboardThirdparties', $parameters, $thirdparty_static);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
static saveboxorder($dbs, $zone, $boxorder, $userid=0)
Save order of boxes for area and user.
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.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.