/** * Overloading the doActions function : replacing the parent's function with the one below * * @param array() $parameters Hook metadatas (context, etc...) * @param CommonObject &$object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...) * @param string &$action Current action (if set). Generally create or edit or null * @param HookManager $hookmanager Hook manager propagated to allow calling another hook * @return int < 0 on error, 0 on success, 1 to replace standard code */ function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) { $error = 0; if (in_array('pricesuppliercard', explode(':', $parameters['context']))) { global $conf, $user, $langs; if (!empty($conf->global->MANDARIN_TRACE_COST_PRICE) && !empty($user->rights->mandarin->graph->product_cost_price)) { define('INC_FROM_DOLIBARR', true); dol_include_once('/mandarin/config.php'); dol_include_once('/mandarin/class/costpricelog.class.php'); $PDOdb = new TPDOdb(); $TData = TProductCostPriceLog::getDataForProduct($PDOdb, $object->id); if (!empty($TData)) { $l = new TListviewTBS('graphrate'); echo $l->renderArray($PDOdb, $TData, array('type' => 'chart', 'curveType' => 'none', 'liste' => array('titre' => $langs->trans('GraphTraceCostPrice')), 'title' => array('PA' => $langs->transnoentities('PricePA'), 'PMP' => $langs->transnoentities('PricePMP'), 'OF' => $langs->transnoentities('PriceOF')))); ?> <script type="text/javascript"> $(document).ready(function() { $('#div_query_chartgraphrate').insertAfter('div.fiche:first'); }); </script> <?php } } } if (!$error) { return 0; // or return 1 to replace standard code } else { $this->errors[] = 'Error message'; return -1; } }
function _print_graph() { global $db, $langs; $PDOdb = new TPDOdb(); $TDataBrut = $TData = _get_projet_cdp(); //var_dump($TDataBrut); $explorer = new stdClass(); $explorer->actions = array("dragToZoom", "rightClickToReset"); $listeview = new TListviewTBS('graphProjectCDP'); print $listeview->renderArray($PDOdb, $TData, array('type' => 'chart', 'chartType' => 'ColumnChart', 'liste' => array('titre' => $langs->transnoentities('graphProjectCDP')), 'hAxis' => array('title' => 'Chef de projet'), 'vAxis' => array('title' => 'Nombre de projets'), 'explorer' => $explorer)); }
function print_rapport() { global $langs; $date_d = preg_replace('/\\//', '-', GETPOST('date_deb')); $date_f = preg_replace('/\\//', '-', GETPOST('date_fin')); $date_deb = date('Y-m-d', strtotime($date_d)); $date_fin = date('Y-m-d', strtotime($date_f)); if (empty(GETPOST('date_deb'))) { $date_deb = date('Y-m-d', strtotime(date('Y-m-d')) - 60 * 60 * 24 * 7); } if (empty(GETPOST('date_fin'))) { $date_fin = date('Y-m-d'); } $PDOdb = new TPDOdb(); $interval = (strtotime($date_fin) - strtotime($date_deb)) / 3600 / 24; $TDataBrut = get_user_capacity_period($date_deb, $date_fin); $TData = array(); $total_temps_saisi = 0; $hours_to_work = _get_hours_to_work($interval); $capacity = $hours_to_work / $interval; foreach ($TDataBrut as $ligne) { $TData[] = array('task_date' => $ligne['task_date'], 'duree' => $ligne['duree'], 'capacity' => $capacity); $total_temps_saisi = $ligne['total']; } $explorer = new stdClass(); $explorer->actions = array("dragToZoom", "rightClickToReset"); $listeview = new TListviewTBS('graphProject'); print $listeview->renderArray($PDOdb, $TData, array('type' => 'chart', 'chartType' => 'ColumnChart', 'liste' => array('titre' => $langs->transnoentities('timeInput')), 'hAxis' => array('title' => 'Date'), 'vAxis' => array('title' => 'Temps'), 'explorer' => $explorer)); print_fiche_titre($langs->trans("Temps saisis/capacité de production")); $percentage = round($total_temps_saisi / $hours_to_work * 100, 2); ?> <div class="tabBar"> <table> <tbody> <tr> <td style="font-weight: bold">Pourcentage heures saisies/capacité de production :</td> <td <?php echo $percentage > 80 ? 'style="font-weight : bold; color : green;"' : 'style="font-weight : bold; color : red;"'; ?> ><?php echo $percentage; ?> %</td> </tr> </tbody> </table> </div> <?php }
WHERE pt.entity = ' . $conf->entity . ' AND pt.fk_projet = ' . $id; if (!empty($progress_min)) { $sql .= ' AND pt.progress >= ' . $progress_min; } if (!empty($progress_max)) { $sql .= ' AND pt.progress >= ' . $progress_max; } $sql .= ' GROUP BY pt.rowid ORDER BY pt.progress'; $resql = $db->query($sql); if ($resql) { while ($line = $db->fetch_object($resql)) { if (empty($line->temps_prevu)) { continue; } $temps_prevu = !empty($line->temps_prevu) ? $line->temps_prevu : 1; $progress_reelle = 100 * $line->temps_reel / $temps_prevu; $progress_theorique = 100 * $line->temps_theorique / $temps_prevu; $TData[] = array('name' => dol_escape_js($line->label) . ' (' . $line->ref . ')', 'Progression réelle' => $progress_reelle, 'Progression théorique' => $progress_theorique); } } // Begin of page llxHeader('', $langs->trans('mandarinTitleGraphProjet'), ''); $head = project_prepare_head($object); dol_fiche_head($head, 'mandarin_rapport', $langs->trans("mandarinProjectTask"), 0, $object->public ? 'projectpub' : 'project'); $explorer = new stdClass(); $explorer->actions = array("dragToZoom", "rightClickToReset"); $listeview = new TListviewTBS('graphProjectTask'); print $listeview->renderArray($PDOdb, $TData, array('type' => 'chart', 'chartType' => 'ColumnChart', 'liste' => array('titre' => $langs->transnoentitiesnoconv('titleGraphProjectTask')), 'xaxis' => 'name', 'hAxis' => array('title' => $langs->transnoentitiesnoconv('subTitleHAxisGraphProjectTask')), 'vAxis' => array('title' => $langs->transnoentitiesnoconv('subTitleVAxisGraphProjectTask')), 'explorer' => $explorer)); // End of page llxFooter();
function draw_graphique(&$TData, &$TabTrad) { global $langs; $PDOdb = new TPDOdb(); $TSum = array(); foreach ($TData as $code => $Tab) { if (empty($TabTrad[$code]['label'])) { continue; } $TSum[] = array($TabTrad[$code]['label'], array_sum($Tab)); } $listeview = new TListviewTBS('graphProjectByType'); print $listeview->renderArray($PDOdb, $TSum, array('type' => 'chart', 'chartType' => 'PieChart', 'liste' => array('titre' => $langs->transnoentitiesnoconv('titleGraphProjectByType')))); }
} _get_company_object($TData); //usort($TData, '_sort_company'); ?> <style type="text/css"> *[field=total],tr.liste_total td { font-weight: bold; } </style> <?php $formCore = new TFormCore('auto', 'form2', 'get'); $headsearch = $formCore->hidden('mode', $mode); $headsearch .= $formCore->combo($langs->trans('Year'), 'year', $TYear, $year); $headsearch .= $formCore->btsubmit($langs->trans('Ok'), 'bt_ok'); $listeview = new TListviewTBS('CAClientMonth'); print $listeview->renderArray($PDOdb, $TData, array('liste' => array('titre' => $langs->transnoentitiesnoconv('CAClientMonth'), 'head_search' => $headsearch), 'type' => $ColFormat, 'title' => array('client' => $langs->transnoentitiesnoconv('Company'), 'total' => $langs->transnoentitiesnoconv('Total'), 'year' => $langs->transnoentitiesnoconv('Year')), 'math' => $ColTotal, 'export' => array('CSV'))); $formCore->end(); dol_fiche_end(); llxFooter(); function _sort_company(&$a, &$b) { $r = strcasecmp($a->name, $b->name); return empty($r) ? 0 : $r / abs($r); } function _get_company_object(&$TRender) { global $db, $conf, $langs, $user; dol_include_once('/societe/class/societe.class.php'); foreach ($TRender as $fk_soc => &$line) { $s = new Societe($db); $s->fetch($fk_soc);
function _stat_wd(&$PDOdb, $id_ws, $tDeb, $tFin) { $ws = new TWorkstation(); $ws->load($PDOdb, $id_ws); $TData = _get_data_ws($PDOdb, $id_ws, $tDeb, $tFin, $ws->nb_ressource); // var_dump($TData); ?> <table class="border" style="margin-top:20px;width:100%;"> <tr> <td><?php echo $ws->getNomUrl(1) . ' du ' . date('d/m/Y', $tDeb) . ' au ' . date('d/m/Y', $tFin); ?> </td> </tr> <tr> <td> <?php $l = new TListviewTBS('stat_ws_' . $id_ws); echo $l->renderArray($PDOdb, $TData, array('type' => 'chart', 'chartType' => 'AreaChart')); ?> </td> </tr> </table> <?php }
} if (empty($line->dds)) { $week_end = 53; } else { $time_dds = strtotime($line->dds); $year_dds = date('Y', $time_dds); if ($year_dds < $year_n) { continue; } else { $week_end = date('W', $time_dds); } } $Tab[] = array('week_start' => $week_start, 'week_end' => $week_end, 'horaire' => $line->weeklyhours); } } if (count($Tab) > 0) { foreach ($Tab as &$TInfo) { for ($i = $TInfo['week_start']; $i <= $TInfo['week_end']; $i++) { $TData[$i]['Dispo CDI'] += $TInfo['horaire']; // Somme des horaires CDI dispo } } } // Begin of page llxHeader('', $langs->trans('mandarinTitleGraphTotalHeure'), ''); $explorer = new stdClass(); $explorer->actions = array("dragToZoom", "rightClickToReset"); $listeview = new TListviewTBS('graphTotalHeure'); print $listeview->renderArray($PDOdb, $TData, array('type' => 'chart', 'liste' => array('titre' => $langs->transnoentitiesnoconv('titleGraphTotalHeure')), 'title' => array('year' => $langs->transnoentitiesnoconv('Year'), 'week' => $langs->transnoentitiesnoconv('Week')), 'xaxis' => 'week', 'hAxis' => array('title' => $langs->transnoentitiesnoconv('subTitleHAxisGraphTotalHeure')), 'vAxis' => array('title' => $langs->transnoentitiesnoconv('subTitleVAxisGraphTotalHeure')), 'explorer' => $explorer)); // End of page llxFooter();
print '<div style="width:50%;display:inline-block;">'; $listeview = new TListviewTBS('graphPalmaresPercentCA'); print $listeview->renderArray($PDOdb, $TValue, array('type' => 'chart', 'chartType' => 'PieChart', 'liste' => array('titre' => $langs->transnoentitiesnoconv('titleGraphPalmaresPercentCA', $year_n_1)))); print '</div>'; // Graph %CA par CC $TPalmaresCAParCC = array(); $TValue = array(); $sql = 'SELECT u.firstname, u.lastname, YEAR(f.datef) AS `year`, SUM(f.total) AS total_ht FROM ' . MAIN_DB_PREFIX . 'facture f INNER JOIN ' . MAIN_DB_PREFIX . 'user u ON (u.rowid = f.fk_user_author) WHERE YEAR(f.datef) = ' . $year_n_1 . ' GROUP BY u.rowid'; $resql = $db->query($sql); if ($resql) { $total_ca; while ($line = $db->fetch_object($resql)) { $name = strtoupper($line->lastname[0]) . '. ' . $line->firstname; $TPalmaresCAParCC[$name] += $line->total_ht; $total_ca += $line->total_ht; } arsort($TPalmaresCAParCC); foreach ($TPalmaresCAParCC as $name => $total) { $TValue[] = array('name' => $name, 'val' => $total); } } print '<div style="width:50%;display:inline-block;">'; $listeview = new TListviewTBS('graphPercentCAPerCC'); print $listeview->renderArray($PDOdb, $TValue, array('type' => 'chart', 'chartType' => 'PieChart', 'liste' => array('titre' => $langs->transnoentitiesnoconv('titleGraphPercentCAPerCC', $year_n_1)))); print '</div>'; // End of page llxFooter();