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 (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
104 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
106$sql .=
' WHERE s.entity IN ('.getEntity(
'societe').
')';
107if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
108 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
110if (!$user->hasRight(
'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') && !
getDolGlobalString(
'SOCIETE_DISABLE_PROSPECTS') && !
getDolGlobalString(
'SOCIETE_DISABLE_PROSPECTS_STATS') && ($objp->client == 2 || $objp->client == 3)) {
129 $third[
'prospect']++;
131 if (isModEnabled(
'societe') && $user->hasRight(
'societe',
'lire') && !
getDolGlobalString(
'SOCIETE_DISABLE_CUSTOMERS') && !
getDolGlobalString(
'SOCIETE_DISABLE_CUSTOMERS_STATS') && ($objp->client == 1 || $objp->client == 3)) {
133 $third[
'customer']++;
135 if (((isModEnabled(
'fournisseur') && $user->hasRight(
'fournisseur',
'lire') && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled(
'supplier_order') && $user->hasRight(
'supplier_order',
'lire')) || (isModEnabled(
'supplier_invoice') && $user->hasRight(
'supplier_invoice',
'lire'))) && !
getDolGlobalString(
'SOCIETE_DISABLE_SUPPLIERS_STATS') && $objp->fournisseur) {
137 $third[
'supplier']++;
139 if (isModEnabled(
'societe') && $objp->client == 0 && $objp->fournisseur == 0) {
151$thirdpartygraph =
'<div class="div-table-responsive-no-min">';
152$thirdpartygraph .=
'<table class="noborder nohover centpercent">'.
"\n";
153$thirdpartygraph .=
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
'</th></tr>';
154if (!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)) {
155 $thirdpartygraph .=
'<tr><td class="center" colspan="2">';
156 $dataseries = array();
157 if (isModEnabled(
'societe') && $user->hasRight(
'societe',
'lire') && !
getDolGlobalString(
'SOCIETE_DISABLE_PROSPECTS') && !
getDolGlobalString(
'SOCIETE_DISABLE_PROSPECTS_STATS')) {
158 $dataseries[] = array($langs->transnoentitiesnoconv(
"Prospects"), round($third[
'prospect']));
160 if (isModEnabled(
'societe') && $user->hasRight(
'societe',
'lire') && !
getDolGlobalString(
'SOCIETE_DISABLE_CUSTOMERS') && !
getDolGlobalString(
'SOCIETE_DISABLE_CUSTOMERS_STATS')) {
161 $dataseries[] = array($langs->transnoentitiesnoconv(
"Customers"), round($third[
'customer']));
163 if (((isModEnabled(
'fournisseur') && $user->hasRight(
'fournisseur',
'lire') && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled(
'supplier_order') && $user->hasRight(
'supplier_order',
'lire')) || (isModEnabled(
'supplier_invoice') && $user->hasRight(
'supplier_invoice',
'lire'))) && !
getDolGlobalString(
'SOCIETE_DISABLE_SUPPLIERS_STATS')) {
164 $dataseries[] = array($langs->transnoentitiesnoconv(
"Suppliers"), round($third[
'supplier']));
166 if (isModEnabled(
'societe')) {
167 $dataseries[] = array($langs->transnoentitiesnoconv(
"Others"), round($third[
'other']));
169 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
171 $dolgraph->SetData($dataseries);
172 $dolgraph->setShowLegend(2);
173 $dolgraph->setShowPercent(1);
174 $dolgraph->SetType(array(
'pie'));
175 $dolgraph->setHeight(
'200');
176 $dolgraph->draw(
'idgraphthirdparties');
177 $thirdpartygraph .= $dolgraph->show();
178 $thirdpartygraph .=
'</td></tr>'.
"\n";
180 if (isModEnabled(
'societe') && $user->hasRight(
'societe',
'lire') && !
getDolGlobalString(
'SOCIETE_DISABLE_PROSPECTS') && !
getDolGlobalString(
'SOCIETE_DISABLE_PROSPECTS_STATS')) {
181 $statstring =
"<tr>";
182 $statstring .=
'<td><a href="'.DOL_URL_ROOT.
'/societe/list.php?type=p">'.$langs->trans(
"Prospects").
'</a></td><td class="right">'.round($third[
'prospect']).
'</td>';
183 $statstring .=
"</tr>";
185 if (isModEnabled(
'societe') && $user->hasRight(
'societe',
'lire') && !
getDolGlobalString(
'SOCIETE_DISABLE_CUSTOMERS') && !
getDolGlobalString(
'SOCIETE_DISABLE_CUSTOMERS_STATS')) {
186 $statstring .=
"<tr>";
187 $statstring .=
'<td><a href="'.DOL_URL_ROOT.
'/societe/list.php?type=c">'.$langs->trans(
"Customers").
'</a></td><td class="right">'.round($third[
'customer']).
'</td>';
188 $statstring .=
"</tr>";
191 if (((isModEnabled(
'fournisseur') && $user->hasRight(
'fournisseur',
'lire') && !
getDolGlobalString(
'MAIN_USE_NEW_SUPPLIERMOD')) || (isModEnabled(
'supplier_order') && $user->hasRight(
'supplier_order',
'lire')) || (isModEnabled(
'supplier_invoice') && $user->hasRight(
'supplier_invoice',
'lire'))) && !
getDolGlobalString(
'SOCIETE_DISABLE_SUPPLIERS_STATS')) {
192 $statstring2 =
"<tr>";
193 $statstring2 .=
'<td><a href="'.DOL_URL_ROOT.
'/societe/list.php?type=f">'.$langs->trans(
"Suppliers").
'</a></td><td class="right">'.round($third[
'supplier']).
'</td>';
194 $statstring2 .=
"</tr>";
196 $thirdpartygraph .= $statstring;
197 $thirdpartygraph .= $statstring2;
199$thirdpartygraph .=
'<tr class="liste_total"><td>'.$langs->trans(
"UniqueThirdParties").
'</td><td class="right">';
200$thirdpartygraph .= $total;
201$thirdpartygraph .=
'</td></tr>';
202$thirdpartygraph .=
'</table>';
203$thirdpartygraph .=
'</div>';
205$thirdpartycateggraph =
'';
206if (isModEnabled(
'categorie') &&
getDolGlobalString(
'CATEGORY_GRAPHSTATS_ON_THIRDPARTIES')) {
207 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
208 $elementtype =
'societe';
210 $thirdpartycateggraph =
'<div class="div-table-responsive-no-min">';
211 $thirdpartycateggraph .=
'<table class="noborder nohover centpercent">';
212 $thirdpartycateggraph .=
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Categories").
'</th></tr>';
213 $thirdpartycateggraph .=
'<tr><td class="center" colspan="2">';
214 $sql =
"SELECT c.label, count(*) as nb";
215 $sql .=
" FROM ".MAIN_DB_PREFIX.
"categorie_societe as cs";
216 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"categorie as c ON cs.fk_categorie = c.rowid";
217 $sql .=
" WHERE c.type = 2";
218 if (!is_numeric($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES)) {
219 $sql .=
" AND c.label like '".$db->escape($conf->global->CATEGORY_GRAPHSTATS_ON_THIRDPARTIES).
"'";
221 $sql .=
" AND c.entity IN (".getEntity(
'category').
")";
222 $sql .=
" GROUP BY c.label";
224 $result = $db->query($sql);
226 $num = $db->num_rows($result);
228 if (!empty($conf->use_javascript_ajax)) {
229 $dataseries = array();
234 $obj = $db->fetch_object($result);
236 $dataseries[] = array($obj->label, round($obj->nb));
244 $dataseries[] = array($langs->trans(
"Other"), round($rest));
246 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
248 $dolgraph->SetData($dataseries);
249 $dolgraph->setShowLegend(2);
250 $dolgraph->setShowPercent(1);
251 $dolgraph->SetType(array(
'pie'));
252 $dolgraph->setHeight(
'200');
253 $dolgraph->draw(
'idgraphcateg');
254 $thirdpartycateggraph .= $dolgraph->show();
257 $obj = $db->fetch_object($result);
259 $thirdpartycateggraph .=
'<tr class="oddeven"><td>'.$obj->label.
'</td><td>'.$obj->nb.
'</td></tr>';
265 $thirdpartycateggraph .=
'</td></tr>';
266 $thirdpartycateggraph .=
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">';
267 $thirdpartycateggraph .= $total;
268 $thirdpartycateggraph .=
'</td></tr>';
269 $thirdpartycateggraph .=
'</table>';
270 $thirdpartycateggraph .=
'</div>';
272 $thirdpartycateggraph =
'';
280$sql =
"SELECT s.rowid, s.nom as name, s.email, s.client, s.fournisseur";
281$sql .=
", s.code_client";
282$sql .=
", s.code_fournisseur";
284 $sql .=
", spe.accountancy_code_supplier as code_compta_fournisseur";
285 $sql .=
", spe.accountancy_code_customer as code_compta";
287 $sql .=
", s.code_compta_fournisseur";
288 $sql .=
", s.code_compta";
292$sql .=
", s.canvas, s.tms as date_modification, s.status as status";
293$sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
295 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
297if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
298 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
300$sql .=
' WHERE s.entity IN ('.getEntity(
'societe').
')';
301if (!$user->hasRight(
'societe',
'client',
'voir') && !$socid) {
302 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
304if (!$user->hasRight(
'fournisseur',
'lire')) {
305 $sql .=
" AND (s.fournisseur != 1 OR s.client != 0)";
308$parameters = array(
'socid' => $socid);
309$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, $thirdparty_static);
310if (empty($reshook)) {
312 $sql .=
" AND s.rowid = ".((int) $socid);
315$sql .= $hookmanager->resPrint;
316$sql .= $db->order(
"s.tms",
"DESC");
317$sql .= $db->plimit($max, 0);
321$result = $db->query($sql);
323 $num = $db->num_rows($result);
328 $transRecordedType = $langs->trans(
"LastModifiedThirdParties", $max);
330 $lastmodified =
"\n<!-- last thirdparties modified -->\n";
331 $lastmodified .=
'<div class="div-table-responsive-no-min">';
332 $lastmodified .=
'<table class="noborder centpercent">';
334 $lastmodified .=
'<tr class="liste_titre"><th colspan="2">'.$transRecordedType.
'</th>';
335 $lastmodified .=
'<th> </th>';
336 $lastmodified .=
'<th class="right"><a href="'.DOL_URL_ROOT.
'/societe/list.php?sortfield=s.tms&sortorder=DESC">'.$langs->trans(
"FullList").
'</th>';
337 $lastmodified .=
'</tr>'.
"\n";
340 $objp = $db->fetch_object($result);
342 $thirdparty_static->id = $objp->rowid;
343 $thirdparty_static->name = $objp->name;
344 $thirdparty_static->client = $objp->client;
345 $thirdparty_static->fournisseur = $objp->fournisseur;
346 $thirdparty_static->logo = $objp->logo;
347 $thirdparty_static->date_modification = $db->jdate($objp->date_modification);
348 $thirdparty_static->status = $objp->status;
349 $thirdparty_static->code_client = $objp->code_client;
350 $thirdparty_static->code_fournisseur = $objp->code_fournisseur;
351 $thirdparty_static->canvas = $objp->canvas;
352 $thirdparty_static->email = $objp->email;
353 $thirdparty_static->entity = $objp->entity;
354 $thirdparty_static->code_compta_fournisseur = $objp->code_compta_fournisseur;
355 $thirdparty_static->code_compta = $objp->code_compta;
357 $lastmodified .=
'<tr class="oddeven">';
359 $lastmodified .=
'<td class="nowrap tdoverflowmax200">';
360 $lastmodified .= $thirdparty_static->getNomUrl(1);
361 $lastmodified .=
"</td>\n";
363 $lastmodified .=
'<td class="center">';
364 $lastmodified .= $thirdparty_static->getTypeUrl();
365 $lastmodified .=
'</td>';
367 $lastmodified .=
'<td class="right tddate" title="'.dol_escape_htmltag($langs->trans(
"DateModification").
' '.
dol_print_date($thirdparty_static->date_modification,
'dayhour',
'tzuserrel')).
'">';
368 $lastmodified .=
dol_print_date($thirdparty_static->date_modification,
'day',
'tzuserrel');
369 $lastmodified .=
"</td>";
370 $lastmodified .=
'<td class="right nowrap">';
371 $lastmodified .= $thirdparty_static->getLibStatut(3);
372 $lastmodified .=
"</td>";
373 $lastmodified .=
"</tr>\n";
379 $lastmodified .=
"</table>\n";
380 $lastmodified .=
'</div>';
381 $lastmodified .=
"<!-- End last thirdparties modified -->\n";
390print
'<div class="clearboth"></div>';
391print
'<div class="fichecenter fichecenterbis">';
393$boxlist =
'<div class="twocolumns">';
395$boxlist .=
'<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
396$boxlist .= $thirdpartygraph;
398$boxlist .= $thirdpartycateggraph;
400$boxlist .= $resultboxes[
'boxlista'];
401$boxlist .=
'</div>'.
"\n";
403$boxlist .=
'<div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
404$boxlist .= $lastmodified;
406$boxlist .= $resultboxes[
'boxlistb'];
407$boxlist .=
'</div>'.
"\n";
415$parameters = array(
'user' => $user);
416$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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.