PageRenderTime 58ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/index.php

https://bitbucket.org/speedealing/speedealing
PHP | 633 lines | 159 code | 40 blank | 434 comment | 14 complexity | bafdf266ccd23cb3f628b3642cdec3b4 MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.1, GPL-3.0, MIT
  1. <?php
  2. /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
  5. * Copyright (C) 2011-2012 Herve Prot <herve.prot@symeos.com>
  6. * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. define('NOCSRFCHECK', 1); // This is login page. We must be able to go on it from another web site.
  22. require("./main.inc.php");
  23. require_once(DOL_DOCUMENT_ROOT . "/core/class/html.formother.class.php");
  24. require_once(DOL_DOCUMENT_ROOT . "/agenda/class/agenda.class.php");
  25. // If not defined, we select menu "home"
  26. $action = GETPOST('action');
  27. // Add index hook
  28. $hookmanager->initHooks(array('index'));
  29. /*
  30. * Actions
  31. */
  32. // Check if company name is defined (first install)
  33. if (!isset($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_NOM)) {
  34. header("Location: " . DOL_URL_ROOT . "/admin/company.php?mainmenu=home&leftmenu=setup&mesg=setupnotcomplete");
  35. exit;
  36. }
  37. /*
  38. * View
  39. */
  40. llxHeader();
  41. if (!empty($conf->global->MAIN_MOTD)) {
  42. $conf->global->MAIN_MOTD = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', '<br>', $conf->global->MAIN_MOTD);
  43. if (!empty($conf->global->MAIN_MOTD)) {
  44. print '<div class="row">';
  45. print '<div class="twelve columns">';
  46. print "\n<!-- Start of welcome text -->\n";
  47. print '<table width="100%" class="notopnoleftnoright"><tr><td>';
  48. print dol_htmlentitiesbr($conf->global->MAIN_MOTD);
  49. print '</td></tr></table><br>';
  50. print "\n<!-- End of welcome text -->\n";
  51. print '</div>';
  52. print '</div>';
  53. }
  54. }
  55. print_fiche_titre($langs->trans("Dashboard"), true);
  56. ?>
  57. <div class="dashboard">
  58. <div class="columns">
  59. <div class="nine-columns twelve-columns-mobile chart">
  60. <div id="demo-chart" style="height: 280px; min-width: 100px"></div>
  61. </div>
  62. <div class="three-columns twelve-columns-mobile new-row-mobile">
  63. <ul class="stats split-on-mobile">
  64. <li><a href="#"> <strong>-</strong> new <br>accounts
  65. </a></li>
  66. <li><a href="#"> <strong>-</strong> referred new <br>accounts
  67. </a></li>
  68. <li><strong>-</strong> new <br>items</li>
  69. <li><strong>-</strong> new <br>comments</li>
  70. </ul>
  71. </div>
  72. </div>
  73. </div>
  74. <?php
  75. print '<div class="with-padding">';
  76. print '<div class="columns">';
  77. /*
  78. * Informations area
  79. */
  80. print column_start("four");
  81. print start_box($langs->trans("Informations"), 'icon-user');
  82. print '<table class="noborder" width="100%">';
  83. print '<tr ' . $bc[false] . '>';
  84. print '<td nowrap="nowrap">' . $langs->trans("User") . '</td><td>' . $user->getNomUrl(0) . '</td></tr>';
  85. print '<tr ' . $bc[true] . '>';
  86. print '<td nowrap="nowrap">' . $langs->trans("PreviousConnexion") . '</td><td>';
  87. if ($user->LastConnection)
  88. print dol_print_date($user->LastConnection, "dayhour");
  89. else
  90. print $langs->trans("Unknown");
  91. print '</td>';
  92. print "</tr>\n";
  93. print "</table>\n";
  94. print end_box();
  95. print column_end();
  96. print column_start("four");
  97. print column_end();
  98. // print today action
  99. print column_start("four");
  100. $agenda = new Agenda($db);
  101. $agenda->print_week(dol_now());
  102. print column_end();
  103. /*
  104. $rowspan = 0;
  105. $dashboardlines = array();
  106. print start_box($langs->trans("SpeedealingWorkBoard"), "eight", "16-Cloud.png");
  107. print '<table class="noborder" width="100%">';
  108. print '<tr class="liste_titre">';
  109. print '<th class="liste_titre"colspan="2">' . $langs->trans("SpeedealingWorkBoard") . '</th>';
  110. print '<th class="liste_titre"align="right">' . $langs->trans("Number") . '</th>';
  111. print '<th class="liste_titre"align="right">' . $langs->trans("Late") . '</th>';
  112. print '<th class="liste_titre">&nbsp;</th>';
  113. print '<th class="liste_titre"width="20">&nbsp;</th>';
  114. print '</tr>';
  115. //
  116. // Do not include sections without management permission
  117. //
  118. // Number of actions to do (late)
  119. if ($conf->agenda->enabled && $user->rights->agenda->myactions->read) {
  120. include_once(DOL_DOCUMENT_ROOT . "/agenda/class/agenda.class.php");
  121. $board = new Agenda($db);
  122. $board->load_board($user);
  123. $board->warning_delay = $conf->actions->warning_delay / 60 / 60 / 24;
  124. $board->label = $langs->trans("ActionsToDo");
  125. $board->url = DOL_URL_ROOT . '/agenda/listactions.php?status=todo&mainmenu=agenda';
  126. $board->img = img_object($langs->trans("Actions"), "action");
  127. $rowspan++;
  128. $dashboardlines[] = $board;
  129. }
  130. // Number of customer orders a deal
  131. if ($conf->commande->enabled && $user->rights->commande->lire) {
  132. include_once(DOL_DOCUMENT_ROOT . "/commande/class/commande.class.php");
  133. $board = new Commande($db);
  134. $board->load_board($user);
  135. $board->warning_delay = $conf->commande->client->warning_delay / 60 / 60 / 24;
  136. $board->label = $langs->trans("OrdersToProcess");
  137. $board->url = DOL_URL_ROOT . '/commande/liste.php?viewstatut=-2';
  138. $board->img = img_object($langs->trans("Orders"), "order");
  139. $rowspan++;
  140. $dashboardlines[] = $board;
  141. }
  142. // Number of suppliers orders a deal
  143. if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire) {
  144. include_once(DOL_DOCUMENT_ROOT . "/fourn/class/fournisseur.commande.class.php");
  145. $board = new CommandeFournisseur($db);
  146. $board->load_board($user);
  147. $board->warning_delay = $conf->commande->fournisseur->warning_delay / 60 / 60 / 24;
  148. $board->label = $langs->trans("SuppliersOrdersToProcess");
  149. $board->url = DOL_URL_ROOT . '/fourn/commande/index.php';
  150. $board->img = img_object($langs->trans("Orders"), "order");
  151. $rowspan++;
  152. $dashboardlines[] = $board;
  153. }
  154. // Number of commercial proposals opened (expired)
  155. if ($conf->propal->enabled && $user->rights->propale->lire) {
  156. $langs->load("propal");
  157. include_once(DOL_DOCUMENT_ROOT . "/comm/propal/class/propal.class.php");
  158. $board = new Propal($db);
  159. $board->load_board($user, "opened");
  160. $board->warning_delay = $conf->propal->cloture->warning_delay / 60 / 60 / 24;
  161. $board->label = $langs->trans("PropalsToClose");
  162. $board->url = DOL_URL_ROOT . '/comm/propal/list.php?viewstatut=1';
  163. $board->img = img_object($langs->trans("Propals"), "propal");
  164. $rowspan++;
  165. $dashboardlines[] = $board;
  166. }
  167. // Number of commercial proposals CLOSED signed (billed)
  168. if ($conf->propal->enabled && $user->rights->propale->lire) {
  169. $langs->load("propal");
  170. include_once(DOL_DOCUMENT_ROOT . "/comm/propal/class/propal.class.php");
  171. $board = new Propal($db);
  172. $board->load_board($user, "signed");
  173. $board->warning_delay = $conf->propal->facturation->warning_delay / 60 / 60 / 24;
  174. $board->label = $langs->trans("PropalsToBill");
  175. $board->url = DOL_URL_ROOT . '/comm/propal/list.php?viewstatut=2';
  176. $board->img = img_object($langs->trans("Propals"), "propal");
  177. $rowspan++;
  178. $dashboardlines[] = $board;
  179. }
  180. // Number of services enabled (delayed)
  181. if ($conf->contrat->enabled && $user->rights->contrat->lire) {
  182. $langs->load("contracts");
  183. include_once(DOL_DOCUMENT_ROOT . "/contrat/class/contrat.class.php");
  184. $board = new Contrat($db);
  185. $board->load_board($user, "inactives");
  186. $board->warning_delay = $conf->contrat->services->inactifs->warning_delay / 60 / 60 / 24;
  187. $board->label = $langs->trans("BoardNotActivatedServices");
  188. $board->url = DOL_URL_ROOT . '/contrat/services.php?mainmenu=commercial&leftmenu=contracts&mode=0';
  189. $board->img = img_object($langs->trans("Contract"), "contract");
  190. $rowspan++;
  191. $dashboardlines[] = $board;
  192. }
  193. // Number of active services (expired)
  194. if ($conf->contrat->enabled && $user->rights->contrat->lire) {
  195. $langs->load("contracts");
  196. include_once(DOL_DOCUMENT_ROOT . "/contrat/class/contrat.class.php");
  197. $board = new Contrat($db);
  198. $board->load_board($user, "expired");
  199. $board->warning_delay = $conf->contrat->services->expires->warning_delay / 60 / 60 / 24;
  200. $board->label = $langs->trans("BoardRunningServices");
  201. $board->url = DOL_URL_ROOT . '/contrat/services.php?mainmenu=commercial&leftmenu=contracts&mode=4&filter=expired';
  202. $board->img = img_object($langs->trans("Contract"), "contract");
  203. $rowspan++;
  204. $dashboardlines[] = $board;
  205. }
  206. // Number of invoices customers (has paid)
  207. if ($conf->facture->enabled && $user->rights->facture->lire) {
  208. $langs->load("bills");
  209. include_once(DOL_DOCUMENT_ROOT . "/compta/facture/class/facture.class.php");
  210. $board = new Facture($db);
  211. $board->load_board($user);
  212. $board->warning_delay = $conf->facture->client->warning_delay / 60 / 60 / 24;
  213. $board->label = $langs->trans("CustomerBillsUnpaid");
  214. $board->url = DOL_URL_ROOT . '/compta/facture/impayees.php';
  215. $board->img = img_object($langs->trans("Bills"), "bill");
  216. $rowspan++;
  217. $dashboardlines[] = $board;
  218. }
  219. // Number of supplier invoices (has paid)
  220. if ($conf->fournisseur->enabled && $conf->facture->enabled && $user->rights->facture->lire) {
  221. $langs->load("bills");
  222. include_once(DOL_DOCUMENT_ROOT . "/fourn/class/fournisseur.facture.class.php");
  223. $board = new FactureFournisseur($db);
  224. $board->load_board($user);
  225. $board->warning_delay = $conf->facture->fournisseur->warning_delay / 60 / 60 / 24;
  226. $board->label = $langs->trans("SupplierBillsToPay");
  227. $board->url = DOL_URL_ROOT . '/fourn/facture/index.php?filtre=paye:0';
  228. $board->img = img_object($langs->trans("Bills"), "bill");
  229. $rowspan++;
  230. $dashboardlines[] = $board;
  231. }
  232. // Number of transactions to conciliate
  233. if ($conf->banque->enabled && $user->rights->banque->lire && !$user->societe_id) {
  234. $langs->load("banks");
  235. include_once(DOL_DOCUMENT_ROOT . "/compta/bank/class/account.class.php");
  236. $board = new Account($db);
  237. $found = $board->load_board($user);
  238. if ($found > 0) {
  239. $board->warning_delay = $conf->bank->rappro->warning_delay / 60 / 60 / 24;
  240. $board->label = $langs->trans("TransactionsToConciliate");
  241. $board->url = DOL_URL_ROOT . '/compta/bank/index.php?leftmenu=bank&mainmenu=bank';
  242. $board->img = img_object($langs->trans("TransactionsToConciliate"), "payment");
  243. $rowspan++;
  244. $dashboardlines[] = $board;
  245. }
  246. }
  247. // Number of cheque to send
  248. if ($conf->banque->enabled && $user->rights->banque->lire && !$user->societe_id) {
  249. $langs->load("banks");
  250. include_once(DOL_DOCUMENT_ROOT . "/compta/paiement/cheque/class/remisecheque.class.php");
  251. $board = new RemiseCheque($db);
  252. $board->load_board($user);
  253. $board->warning_delay = $conf->bank->cheque->warning_delay / 60 / 60 / 24;
  254. $board->label = $langs->trans("BankChecksToReceipt");
  255. $board->url = DOL_URL_ROOT . '/compta/paiement/cheque/index.php?leftmenu=checks&mainmenu=accountancy';
  256. $board->img = img_object($langs->trans("BankChecksToReceipt"), "payment");
  257. $rowspan++;
  258. $dashboardlines[] = $board;
  259. }
  260. // Number of foundation members
  261. if ($conf->adherent->enabled && $user->rights->adherent->lire && !$user->societe_id) {
  262. $langs->load("members");
  263. include_once(DOL_DOCUMENT_ROOT . "/adherent/class/adherent.class.php");
  264. $board = new Adherent($db);
  265. $board->load_board($user);
  266. $board->warning_delay = $conf->adherent->cotisation->warning_delay / 60 / 60 / 24;
  267. $board->label = $langs->trans("MembersWithSubscriptionToReceive");
  268. $board->url = DOL_URL_ROOT . '/adherent/list.php?mainmenu=members';
  269. $board->img = img_object($langs->trans("Members"), "user");
  270. $rowspan++;
  271. $dashboardlines[] = $board;
  272. }
  273. // Calculate total nb of late
  274. $totallate = 0;
  275. foreach ($dashboardlines as $key => $board) {
  276. if ($board->nbtodolate > 0)
  277. $totallate+=$board->nbtodolate;
  278. }
  279. // Show dashboard
  280. $var = true;
  281. foreach ($dashboardlines as $key => $board) {
  282. $var = !$var;
  283. print '<tr ' . $bc[$var] . '><td width="16">' . $board->img . '</td><td>' . $board->label . '</td>';
  284. print '<td align="right"><a href="' . $board->url . '">' . $board->nbtodo . '</a></td>';
  285. print '<td align="right">';
  286. print '<a href="' . $board->url . '">';
  287. print $board->nbtodolate;
  288. print '</a></td>';
  289. print '<td align="left">';
  290. if ($board->nbtodolate > 0)
  291. print img_picto($langs->trans("NActionsLate", $board->nbtodolate), "warning");
  292. else
  293. print '&nbsp;';
  294. print '</td>';
  295. print '<td nowrap="nowrap" align="right">';
  296. print ' (>' . ceil($board->warning_delay) . ' ' . $langs->trans("days") . ')';
  297. print '</td>';
  298. print '</tr>';
  299. print "\n";
  300. }
  301. print '</table>'; // End table array
  302. print end_box();
  303. */
  304. /*
  305. * Dashboard Speedealing states (statistics)
  306. * Hidden for external users
  307. */
  308. $langs->load("commercial");
  309. $langs->load("bills");
  310. $langs->load("orders");
  311. /*if ($user->societe_id == 0) {
  312. print start_box($langs->trans("SpeedealingStateBoard"), 'four', '16-Graph.png');
  313. print '<table class="noborder" width="100%">';
  314. $var = true;
  315. // Condition to be checked for each display line dashboard
  316. $conditions = array(
  317. !empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS_STATS),
  318. !empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_PROSPECTS_STATS),
  319. !empty($conf->societe->enabled) && $user->rights->societe->lire && empty($conf->global->SOCIETE_DISABLE_SUSPECTS_STATS),
  320. !empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire && empty($conf->global->SOCIETE_DISABLE_SUPPLIERS_STATS),
  321. !empty($conf->adherent->enabled) && $user->rights->adherent->lire,
  322. !empty($conf->product->enabled) && $user->rights->produit->lire,
  323. !empty($conf->service->enabled) && $user->rights->service->lire,
  324. !empty($conf->propal->enabled) && $user->rights->propale->lire,
  325. !empty($conf->lead->enabled) && $user->rights->lead->lire,
  326. !empty($conf->commande->enabled) && $user->rights->commande->lire,
  327. !empty($conf->facture->enabled) && $user->rights->facture->lire,
  328. !empty($conf->societe->enabled) && $user->rights->contrat->activer);
  329. // Class file containing the method load_state_board for each line
  330. $includes = array("/societe/class/societe.class.php",
  331. "/societe/class/societe.class.php",
  332. "/societe/class/societe.class.php",
  333. "/fourn/class/fournisseur.class.php",
  334. "/adherent/class/adherent.class.php",
  335. "/product/class/product.class.php",
  336. "/product/class/service.class.php",
  337. "/comm/propal/class/propal.class.php",
  338. "/lead/class/lead.class.php",
  339. "/commande/class/commande.class.php",
  340. "/compta/facture/class/facture.class.php",
  341. "/contrat/class/contrat.class.php");
  342. // Name class containing the method load_state_board for each line
  343. $classes = array('Societe',
  344. 'Societe',
  345. 'Societe',
  346. 'Fournisseur',
  347. 'Adherent',
  348. 'Product',
  349. 'Service',
  350. 'Propal',
  351. 'Lead',
  352. 'Commande',
  353. 'Facture',
  354. 'Contrat');
  355. // Cle array returned by the method load_state_board for each line
  356. $keys = array('customer',
  357. 'prospect',
  358. 'suspect',
  359. 'suppliers',
  360. 'members',
  361. 'products',
  362. 'services',
  363. 'proposals',
  364. 'leads',
  365. 'orders',
  366. 'invoices',
  367. 'Contracts');
  368. // Dashboard Icon lines
  369. $icons = array('company',
  370. 'company',
  371. 'company',
  372. 'company',
  373. 'user',
  374. 'product',
  375. 'service',
  376. 'propal',
  377. 'lead',
  378. 'order',
  379. 'bill',
  380. 'order');
  381. // Translation keyword
  382. $titres = array("Customers",
  383. "Prospects",
  384. "Suspects",
  385. "Suppliers",
  386. "Members",
  387. "Products",
  388. "Services",
  389. "CommercialProposals",
  390. "Leads",
  391. "CustomersOrders",
  392. "BillsCustomers",
  393. "Contracts");
  394. // Dashboard Link lines
  395. $links = array('/comm/list.php?type=2',
  396. '/comm/list.php?type=1',
  397. '/comm/list.php?type=0',
  398. '/fourn/liste.php',
  399. '/adherent/list.php?mainmenu=members',
  400. '/product/liste.php?type=0&amp;mainmenu=products',
  401. '/product/liste.php?type=1&amp;mainmenu=products',
  402. '/comm/propal.php?mainmenu=commercial',
  403. '/lead/liste.php',
  404. '/commande/liste.php?mainmenu=commercial',
  405. '/compta/facture.php?mainmenu=accountancy',
  406. '/contrat/liste.php');
  407. // Translation lang files
  408. $langfile = array("bills",
  409. "prospects",
  410. "prospects",
  411. "suppliers",
  412. "members",
  413. "products",
  414. "produts",
  415. "propal",
  416. "lead@lead",
  417. "orders",
  418. "bills",
  419. "Contracts");
  420. // Loop and displays each line of table
  421. foreach ($keys as $key => $val) {
  422. if ($conditions[$key]) {
  423. $classe = $classes[$key];
  424. // Search in cache if load_state_board is already realized
  425. if (!isset($boardloaded[$classe]) || !is_object($boardloaded[$classe])) {
  426. dol_include_once($includes[$key]);
  427. $board = new $classe($db);
  428. $board->load_state_board($user);
  429. $boardloaded[$classe] = $board;
  430. }
  431. else
  432. $board = $boardloaded[$classe];
  433. $var = !$var;
  434. if ($langfile[$key])
  435. $langs->load($langfile[$key]);
  436. $title = $langs->trans($titres[$key]);
  437. print '<tr ' . $bc[$var] . '><td width="16"><a href="' . dol_buildpath($links[$key], 1) . '">' . img_object($title, $icons[$key]) . '</a></td>';
  438. print '<td>' . $title . '</td>';
  439. print '<td align="right"><a href="' . dol_buildpath($links[$key], 1) . '">' . $board->nb[$val] . '</a></td>';
  440. print '</tr>';
  441. }
  442. }
  443. $object = new stdClass();
  444. $parameters = array();
  445. $action = '';
  446. $reshook = $hookmanager->executeHooks('addStatisticLine', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  447. print '</table>';
  448. print end_box();
  449. }*/
  450. /*
  451. * Show boxes
  452. */
  453. //print '<div class="twelve-columns">';
  454. //FormOther::printBoxesArea($user, "0");
  455. //print '</div></div>';
  456. /*
  457. * Show security warnings
  458. */
  459. // Security warning repertoire install existe (si utilisateur admin)
  460. if ($user->admin && empty($conf->global->MAIN_REMOVE_INSTALL_WARNING)) {
  461. $message = '';
  462. // Check if install lock file is present
  463. $lockfile = DOL_DATA_ROOT . '/install.lock';
  464. if (!empty($lockfile) && !file_exists($lockfile) && is_dir(DOL_DOCUMENT_ROOT . "/install")) {
  465. $langs->load("errors");
  466. //if (! empty($message)) $message.='<br>';
  467. $message.=info_admin($langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT) . ' ' . $langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT . "/install"));
  468. }
  469. // Conf files must be in read only mode
  470. if (is_writable($conffile)) {
  471. $langs->load("errors");
  472. //$langs->load("other");
  473. //if (! empty($message)) $message.='<br>';
  474. $message.=info_admin($langs->transnoentities("WarningConfFileMustBeReadOnly") . ' ' . $langs->trans("WarningUntilDirRemoved", DOL_DOCUMENT_ROOT . "/install"));
  475. }
  476. if ($message) {
  477. print '</br><div class="row">';
  478. print '<div class="twelve column">';
  479. print $message;
  480. print '</div>';
  481. print '</div>';
  482. //$message.='<br>';
  483. //print info_admin($langs->trans("WarningUntilDirRemoved",DOL_DOCUMENT_ROOT."/install"));
  484. }
  485. }
  486. print '</div></div>';
  487. ?>
  488. <!-- Charts library -->
  489. <script type="text/javascript">
  490. $(document).ready(function() {
  491. (function($){ // encapsulate jQuery
  492. $(function() {
  493. var seriesOptions = [],
  494. yAxisOptions = [],
  495. seriesCounter = 0,
  496. names = ['MSFT', 'AAPL', 'GOOG'],
  497. colors = Highcharts.getOptions().colors;
  498. $.each(names, function(i, name) {
  499. $.getJSON('<?php echo DOL_URL_ROOT;?>/core/ajax/listgraphexample.php?filename='+ name.toLowerCase() +'-c.json&callback=?', function(data) {
  500. seriesOptions[i] = {
  501. name: name,
  502. data: data
  503. };
  504. // As we're loading the data asynchronously, we don't know what order it will arrive. So
  505. // we keep a counter and create the chart when all the data is loaded.
  506. seriesCounter++;
  507. if (seriesCounter == names.length) {
  508. createChart();
  509. }
  510. })
  511. .error(function() {log.console;});
  512. });
  513. // create the chart when all data is loaded
  514. function createChart() {
  515. chart = new Highcharts.StockChart({
  516. chart: {
  517. renderTo: 'demo-chart'
  518. },
  519. navigator : {
  520. enabled : true
  521. },
  522. rangeSelector: {
  523. selected: 4
  524. },
  525. yAxis: {
  526. labels: {
  527. formatter: function() {
  528. return (this.value > 0 ? '+' : '') + this.value + '%';
  529. }
  530. },
  531. plotLines: [{
  532. value: 0,
  533. width: 2,
  534. color: 'silver'
  535. }]
  536. },
  537. plotOptions: {
  538. series: {
  539. compare: 'percent'
  540. }
  541. },
  542. tooltip: {
  543. pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.y}</b> ({point.change}%)<br/>',
  544. valueDecimals: 2
  545. },
  546. series: seriesOptions
  547. });
  548. }
  549. });
  550. })(jQuery);
  551. });
  552. </script>
  553. <?php
  554. llxFooter();
  555. /* ?>
  556. <script>
  557. $('#demo-chart').onresize(function () {
  558. chart.setSize(document.getElementById("demo-chart").offsetWidth,300);
  559. });
  560. </script>
  561. <?php */
  562. ?>