/** * 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 _liste(&$PDOdb) { global $langs; $l = new TListviewTBS('listHero'); //requete récupérant les attributs de chaque héro $sql = " SELECT rowid as ID, name, description FROM " . MAIN_DB_PREFIX . "hero"; //affichage du template //utilisation de tableaux imbriqués : // le premier tableau définit les lignes // les sous tableaux correspondent chacun a une colonne et aux valeurs correspondantes echo $l->render($PDOdb, $sql, array('link' => array('name' => '<a href="?action=view&id=@ID@">@val@</a>'), 'title' => array('name' => $langs->trans('Name')), 'hide' => array('entity', 'active'), 'search' => array('name' => true))); }
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 }
function liste() { global $langs, $conf, $user; $PDOdb = new TPDOdb(); llxHeader('', 'Query DashBoard', '', '', 0, 0, array('/query/js/dashboard.js', '/query/js/jquery.gridster.min.js'), array('/query/css/dashboard.css', '/query/css/jquery.gridster.min.css')); dol_fiche_head(); $sql = "SELECT qd.rowid as 'Id', qd.title , '' as 'delete'\n\tFROM " . MAIN_DB_PREFIX . "qdashboard qd\n\tWHERE 1\n\t"; if ($user->admin) { null; } else { $sql .= " AND (qd.fk_user_author=" . $user->id . " OR qd.fk_usergroup IN (SELECT fk_usergroup FROM " . MAIN_DB_PREFIX . "usergroup_user WHERE fk_user="******" ) )"; } $r = new TListviewTBS('lDash'); echo $r->render($PDOdb, $sql, array('link' => array('Id' => '<a href="?action=view&id=@val@">' . img_picto('Edit', 'edit.png') . ' @val@</a>', 'title' => '<a href="?action=run&id=@Id@">' . img_picto('Run', 'object_cron.png') . ' @val@</a>', 'delete' => '<a href="?action=delete&id=@Id@" onclick="return(confirm(\'' . $langs->trans('ConfirmDeleteMessage') . '\'));">' . img_picto('Delete', 'delete.png') . '</a>'), 'title' => array('title' => $langs->trans('Title'), 'delete' => $langs->trans('DeleteQuery')))); dol_fiche_end(); llxFooter(); }
function _list(&$PDOdb) { global $langs, $conf, $user, $db; llxHeader(); dol_fiche_head(array(), 'menu', 'Menu'); $l = new TListviewTBS('lMenu'); $sql = "SELECT rowid,title, type_menu, tab_object, mainmenu,leftmenu,date_cre \n\tFROM " . MAIN_DB_PREFIX . "query_menu \n\tWHERE entity IN (0," . $conf->entity . ")"; $menu_static = new TQueryMenu(); echo $l->render($PDOdb, $sql, array('title' => array('title' => $langs->trans('Title'), 'leftmenu' => $langs->trans('LeftMenu'), 'mainmenu' => $langs->trans('MainMenu'), 'date_cre' => $langs->trans('Date'), 'tab_object' => $langs->trans('TabsObject'), 'type_menu' => $langs->trans('TypeMenu')), 'translate' => array('tab_object' => $menu_static->TTabObject, 'type_menu' => $menu_static->TTypeMenu), 'link' => array('title' => '<a href="?id=@rowid@&action=edit">@val@</a>'), 'hide' => array('rowid'), 'type' => array('date_cre' => 'date'))); /*$kiwi = new TKiwi; $kiwi->fk_soc = $object->id; $kiwi->fk_product = 1; $kiwi->save($PDOdb); */ // pied de page dol_fiche_end(); llxFooter(); }
function _list(&$PDOdb) { global $langs, $conf, $user, $db; llxHeader(); $url = 'lib/adminer/?'; //TODO genrate read profile /* $url.='&server='.$dolibarr_main_db_host; $url.='&db='.$dolibarr_main_db_name; $url.='&username='******'&password='******'&driver='.$dolibarr_main_db_type; */ ?> <a href="<?php echo $url; ?> " class="butAction" target="_blank">Accès à la base de données</a> <?php if (!empty($user->rights->query->bdd->use_other_db)) { dol_fiche_head(array(), 'bdd', 'BDD'); $l = new TListviewTBS('lMenu'); $sql = "SELECT rowid, host, db_name,login,port,charset, '' as 'alive'\n\tFROM " . MAIN_DB_PREFIX . "query_bdd_connector \n\tWHERE entity IN (0," . $conf->entity . ")"; echo $l->render($PDOdb, $sql, array('title' => array('host' => $langs->trans('Host'), 'db_name' => $langs->trans('DBName'), 'port' => $langs->trans('Port'), 'charset' => $langs->trans('Charset'), 'login' => $langs->trans('Login'), 'alive' => $langs->trans('Alive')), 'link' => array('host' => '<a href="?id=@rowid@&action=edit">@val@</a>'), 'hide' => array('rowid'), 'type' => array('date_cre' => 'date'), 'eval' => array('alive' => '_test_alive(@rowid@)'))); /*$kiwi = new TKiwi; $kiwi->fk_soc = $object->id; $kiwi->fk_product = 1; $kiwi->save($PDOdb); */ // pied de page dol_fiche_end(); } llxFooter(); }
$TData[$row->fk_soc]['total'] += (double) $row->total; } _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);
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 }
function _liste(&$PDOdb) { global $langs, $db, $user, $conf; llxHeader('', $langs->trans('ListOFAsset'), '', ''); //getStandartJS(); if (isset($_REQUEST['delete_ok'])) { ?> <br><div class="error"><?php echo $langs->trans('OFAssetDeleted'); ?> </div><br> <?php } $fk_soc = __get('fk_soc', 0, 'integer'); $fk_product = __get('fk_product', 0, 'integer'); $fk_commande = __get('fk_commande', 0, 'integer'); if ($fk_product > 0) { dol_include_once('/core/lib/product.lib.php'); $product = new Product($db); $result = $product->fetch($fk_product); $head = product_prepare_head($product, $user); $titre = $langs->trans("CardProduct" . $product->type); $picto = $product->type == 1 ? 'service' : 'product'; dol_fiche_head($head, 'tabOF2', $titre, 0, $picto); } elseif ($fk_commande > 0) { dol_include_once("/core/lib/order.lib.php"); $commande = new Commande($db); $result = $commande->fetch($fk_commande); $head = commande_prepare_head($commande, $user); $titre = $langs->trans("CustomerOrder" . $product->type); dol_fiche_head($head, 'tabOF3', $titre, 0, "order"); } $form = new TFormCore(); $assetOf = new TAssetOF(); $r = new TSSRenderControler($assetOf); $sql = "SELECT ofe.rowid, ofe.numero, ofe.fk_soc, s.nom as client, SUM(ofel.qty) as nb_product_to_make\n\t\t, GROUP_CONCAT(DISTINCT ofel.fk_product SEPARATOR ',') as fk_product, p.label as product, ofe.ordre, ofe.date_lancement , ofe.date_besoin, ofe.fk_commande,ofe.fk_project\n\t\t, ofe.status, ofe.fk_user,ofe.total_estimated_cost, ofe.total_cost, '' AS printTicket\n\t\t FROM " . MAIN_DB_PREFIX . "assetOf as ofe \n\t\t LEFT JOIN " . MAIN_DB_PREFIX . "assetOf_line ofel ON (ofel.fk_assetOf=ofe.rowid AND ofel.type = 'TO_MAKE')\n\t\t LEFT JOIN " . MAIN_DB_PREFIX . "product p ON (p.rowid = ofel.fk_product)\n\t\t LEFT JOIN " . MAIN_DB_PREFIX . "societe s ON (s.rowid = ofe.fk_soc)\n\t\t WHERE ofe.entity=" . $conf->entity; if ($fk_soc > 0) { $sql .= " AND ofe.fk_soc=" . $fk_soc; } if ($fk_product > 0) { $sql .= " AND ofel.fk_product=" . $fk_product; } if ($fk_commande > 0) { $sql .= " AND ofe.fk_commande=" . $fk_commande; } $sql .= " GROUP BY ofe.rowid "; // TODO je me rappelle plus pourquoi j'ai fait cette merde mais ça fait planter le tri, donc à virer. /*if($conf->global->ASSET_OF_LIST_BY_ROWID_DESC) $orderBy['ofe.rowid']='DESC'; else $orderBy['ofe.date_cre']='DESC';*/ $TMath = array(); $THide = array('rowid', 'fk_user', 'fk_product', 'fk_soc'); if ($fk_commande > 0) { $THide[] = 'fk_commande'; } if ($conf->global->OF_NB_TICKET_PER_PAGE == -1) { $THide[] = 'printTicket'; } if (empty($user->rights->of->of->price)) { $THide[] = 'total_cost'; $THide[] = 'total_estimated_cost'; } else { $TMath['total_estimated_cost'] = 'sum'; $TMath['total_cost'] = 'sum'; } if (!empty($fk_product)) { $TMath['nb_product_to_make'] = 'sum'; } $form = new TFormCore($_SERVER['PHP_SELF'], 'form', 'GET'); echo $form->hidden('action', ''); if ($fk_commande > 0) { echo $form->hidden('fk_commande', $fk_commande); } if ($fk_product > 0) { echo $form->hidden('fk_product', $fk_product); } // permet de garder le filtre produit quand on est sur l'onglet OF d'une fiche produit $r->liste($PDOdb, $sql, array('limit' => array('nbLine' => $conf->liste_limit), 'orderBy' => $orderBy, 'subQuery' => array(), 'link' => array('Utilisateur en charge' => '<a href="' . dol_buildpath('/user/card.php?id=@fk_user@', 2) . '">' . img_picto('', 'object_user.png', '', 0) . ' @val@</a>', 'numero' => '<a href="' . dol_buildpath('/of/fiche_of.php?id=@rowid@"', 2) . '>' . img_picto('', 'object_list.png', '', 0) . ' @val@</a>', 'printTicket' => '<input style=width:40px;"" type="number" value="' . (int) $conf->global->OF_NB_TICKET_PER_PAGE . '" name="printTicket[@rowid@]" min="0" />'), 'translate' => array(), 'hide' => $THide, 'type' => array('date_lancement' => 'date', 'date_besoin' => 'date', 'total_cost' => 'money', 'total_estimated_cost' => 'money', 'nb_product_to_make' => 'number'), 'math' => $TMath, 'liste' => array('titre' => $langs->trans('ListOFAsset'), 'image' => img_picto('', 'title.png', '', 0), 'picto_precedent' => img_picto('', 'back.png', '', 0), 'picto_suivant' => img_picto('', 'next.png', '', 0), 'noheader' => (int) isset($_REQUEST['fk_soc']) | (int) isset($_REQUEST['fk_product']), 'messageNothing' => "Il n'y a aucun " . $langs->trans('OFAsset') . " à afficher", 'picto_search' => img_picto('', 'search.png', '', 0)), 'title' => array('numero' => 'Numéro', 'fk_commande' => 'Commande client', 'ordre' => 'Priorité', 'date_lancement' => 'Date du lancement', 'date_besoin' => 'Date du besoin', 'status' => 'Status', 'login' => 'Utilisateur en charge', 'product' => 'Produit', 'client' => 'Client', 'nb_product_to_make' => 'Nb produits à fabriquer', 'total_cost' => 'Coût réel', 'total_estimated_cost' => 'Coût prévu', 'printTicket' => 'impression<br />étiquette', 'fk_project' => 'Projet'), 'orderBy' => array('rowid' => 'DESC'), 'eval' => array('ordre' => 'TAssetOF::ordre(@val@)', 'status' => 'TAssetOF::status(@val@)', 'product' => 'get_format_libelle_produit("@fk_product@")', 'client' => 'get_format_libelle_societe(@fk_soc@)', 'fk_commande' => 'get_format_libelle_commande(@fk_commande@)', 'fk_project' => 'get_format_libelle_projet(@fk_project@)'), 'search' => array('numero' => array('recherche' => true, 'table' => 'ofe'), 'date_lancement' => array('recherche' => 'calendars', 'table' => 'ofe'), 'date_besoin' => array('recherche' => 'calendars', 'table' => 'ofe'), 'status' => array('recherche' => TAssetOF::$TStatus, 'table' => 'ofe')))); if ($conf->global->OF_NB_TICKET_PER_PAGE != -1) { echo '<p align="right"><input class="button" type="button" onclick="$(this).closest(\'form\').find(\'input[name=action]\').val(\'printTicket\'); $(this).closest(\'form\').submit(); " name="print" value="' . $langs->trans('ofPrintTicket') . '" /></p>'; } $form->end(); // On n'affiche pas le bouton de création d'OF si on est sur la liste OF depuis l'onglet "OF" de la fiche commande if ($fk_commande) { $commande = new Commande($db); $commande->fetch($fk_commande); $r2 = new TSSRenderControler($assetOf); $sql = "SELECT c.rowid as fk_commandedet, p.rowid as rowid, p.ref as refProd, p.label as nomProd, c.qty as qteCommandee, c.description, c.product_type"; $sql .= " FROM " . MAIN_DB_PREFIX . "commandedet c LEFT JOIN " . MAIN_DB_PREFIX . "product p"; $sql .= " ON (c.fk_product = p.rowid)"; $sql .= " WHERE c.product_type IN (0,9) AND c.fk_commande = " . $fk_commande; $resql = $db->query($sql); //var_dump($db); $num = $db->num_rows($resql); print_barre_liste($langs->trans('ListOrderProducts'), $page, "liste.php", $param, $sortfield, $sortorder, '', $num); $i = 0; $form = new TFormCore($_SERVER['PHP_SELF'], 'formMakeOk', 'post'); echo $form->hidden('fk_commande', __get('fk_commande', 0, 'int')); echo $form->hidden('action', 'createOFCommande'); echo $form->hidden('fk_soc', $commande->socid); echo $form->hidden('token', $_SESSION['newtoken']); print '<table class="noborder" width="100%">'; print '<tr class="liste_titre">'; print_liste_field_titre("#"); print_liste_field_titre($langs->trans("Ref"), "liste_of.php", "ref", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Label"), "liste_of.php", "label", "", $param, 'align="left"', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Quantité à produire"), "liste_of.php", "", "", $param, '', $sortfield, $sortorder); print_liste_field_titre($langs->trans("Produits à ajouter à un OF"), "liste_of.php", "", "", $param, '', $sortfield, $sortorder); print "</tr>\n"; $var = 1; $bc = array(1 => 'class="pair"', -1 => 'class="impair"'); while ($prod = $db->fetch_object($resql)) { $var = !$var; //print "<tr ".$bc[$var].">"; if ($prod->product_type == 9) { print "<tr>"; print "<td> </td>"; print "<td colspan=\"4\"><strong>"; print $prod->description; print '</strong></td>'; } else { if (empty($prod->rowid)) { // ligne libre print "<tr>"; print "<td> </td>"; print "<td colspan=\"4\">"; print $prod->description; print '</td>'; } else { print "<tr " . $bc[$var] . ">"; print "<td>" . ($i + 1) . "</td>"; print "<td>"; $p_static = new Product($db); $p_static->ref = $prod->refProd; $p_static->id = $prod->rowid; print $p_static->getNomUrl(1); print "</td>\n"; print '<td>'; print $prod->nomProd; print '</td>'; print "<td>"; print $form->texte('', 'TQuantites[' . $prod->fk_commandedet . ']', $prod->qteCommandee, 3, 255); print "</td>"; print "<td>" . $form->checkbox1('', 'TProducts[' . $prod->fk_commandedet . '][' . (int) $prod->rowid . ']', false, true, '', 'checkOF'); print "</td>"; print "</tr>\n"; $i++; } } } print '<tr class="liste_titre">'; echo '<th class="liste_titre" colspan="2"> </th><th class="liste_titre"> </th><th class="liste_titre"> </th> <th class="liste_titre"><input type="checkbox" id="checkall" checked="checked" value="1"></th> '; print '</tr>'; print "</table>"; ?> <script type="text/javascript"> $('input#checkall').change(function() { $('input.checkOF').prop('checked',$(this).is(':checked')); }); </script> <?php echo '<p align="right">' . $form->btsubmit('Créer OFs', 'subForm') . ' ' . $form->btsubmit('Créer un seul OF', 'subFormAlone') . '</p>'; $form->end(); echo '</div>'; $db->free($resql); } else { if (!empty($fk_product)) { $sql = "SELECT ofe.rowid, ofe.numero, ofe.fk_soc, s.nom as client, SUM(IF(ofel.qty>0,ofel.qty,ofel.qty_needed) ) as nb_product_needed, ofel.fk_product, p.label as product, ofe.ordre, ofe.date_lancement , ofe.date_besoin\n , ofe.status, ofe.fk_user, ofe.total_cost\n FROM " . MAIN_DB_PREFIX . "assetOf as ofe \n LEFT JOIN " . MAIN_DB_PREFIX . "assetOf_line ofel ON (ofel.fk_assetOf=ofe.rowid AND ofel.type = 'NEEDED')\n LEFT JOIN " . MAIN_DB_PREFIX . "product p ON p.rowid = ofel.fk_product\n LEFT JOIN " . MAIN_DB_PREFIX . "societe s ON s.rowid = ofe.fk_soc\n WHERE ofe.entity=" . $conf->entity . " AND ofel.fk_product=" . $fk_product . " AND ofe.status!='CLOSE'"; $sql .= " GROUP BY ofe.rowid "; if ($conf->global->ASSET_OF_LIST_BY_ROWID_DESC) { $orderBy['ofe.rowid'] = 'DESC'; } else { $orderBy['ofe.date_cre'] = 'DESC'; } $TMath = array(); $THide = array('rowid', 'fk_user', 'fk_product', 'fk_soc'); if (empty($user->rights->asset->of->price)) { $THide[] = 'total_cost'; } else { $TMath['total_cost'] = 'sum'; } $TMath['nb_product_needed'] = 'sum'; $l = new TListviewTBS('listeofproductneeded'); echo $langs->trans('ofListProductNeeded'); echo $l->render($PDOdb, $sql, array('limit' => array('nbLine' => $conf->liste_limit), 'orderBy' => $orderBy, 'subQuery' => array(), 'link' => array('Utilisateur en charge' => '<a href="' . dol_buildpath('/user/card.php?id=@fk_user@', 2) . '">' . img_picto('', 'object_user.png', '', 0) . ' @val@</a>', 'numero' => '<a href="' . dol_buildpath('/of/fiche_of.php?id=@rowid@', 2) . '">' . img_picto('', 'object_list.png', '', 0) . ' @val@</a>', 'product' => '<a href="' . dol_buildpath('/product/card.php?id=@fk_product@', 2) . '">' . img_picto('', 'object_product.png', '', 0) . ' @val@</a>', 'client' => '<a href="' . dol_buildpath('/societe/soc.php?id=@fk_soc@', 2) . '">' . img_picto('', 'object_company.png', '', 0) . ' @val@</a>'), 'translate' => array(), 'hide' => $THide, 'type' => array('date_lancement' => 'date', 'date_besoin' => 'date', 'total_cost' => 'money', 'nb_product_needed' => 'number'), 'math' => $TMath, 'liste' => array('titre' => $langs->trans('ListOFAsset'), 'image' => img_picto('', 'title.png', '', 0), 'picto_precedent' => img_picto('', 'back.png', '', 0), 'picto_suivant' => img_picto('', 'next.png', '', 0), 'noheader' => (int) isset($_REQUEST['fk_soc']) | (int) isset($_REQUEST['fk_product']), 'messa geNothing' => "Il n'y a aucun " . $langs->trans('OFAsset') . " à afficher", 'picto_search' => img_picto('', 'search.png', '', 0)), 'title' => array('numero' => 'Numéro', 'ordre' => 'Priorité', 'date_lancement' => 'Date du lancement', 'date_besoin' => 'Date du besoin', 'status' => 'Status', 'login' => 'Utilisateur en charge', 'product' => 'Produit', 'client' => 'Client', 'nb_product_needed' => 'Nb produits nécessaire', 'total_cost' => 'Coût'), 'eval' => array('ordre' => 'TAssetOF::ordre(@val@)', 'status' => 'TAssetOF::status(@val@)', 'product' => 'get_format_libelle_produit(@fk_product@)', 'client' => 'get_format_libelle_societe(@fk_soc@)'))); } echo '<div class="tabsAction">'; echo '<a id="bt_createOf" class="butAction" href="fiche_of.php?action=new' . (!empty($fk_product) ? '&fk_product=' . $fk_product : '') . '">' . $langs->trans('CreateOFAsset') . '</a>'; if ($conf->nomenclature->enabled && !empty($fk_product)) { dol_include_once('/core/class/html.form.class.php'); dol_include_once('/asset/lib/asset.lib.php'); dol_include_once('/nomenclature/class/nomenclature.class.php'); $doliForm = new Form($db); echo $doliForm->selectarray('fk_nomenclature', TNomenclature::get($PDOdb, $fk_product, true)); echo '<script type="text/javascript"> var url_create_of = $("#bt_createOf").attr("href"); $("#bt_createOf").attr("href","#"); $("#bt_createOf").click(function() { var fk_nomenclature = $("select[name=fk_nomenclature]").val(); var href = url_create_of + "&fk_nomenclature=" + fk_nomenclature; $(this).attr("href", href); }); </script>'; } echo '</div>'; } $PDOdb->close(); 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')))); }
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();
$sql = "SELECT l.fk_product, ROUND(SUM(l.qty_used),3) as qty,l.fk_nomenclature"; if (!empty($conf->global->NOMENCLATURE_ACTIVATE_DETAILS_COSTS)) { $sql .= ", n.totalPRCMO_PMP,n.totalPRCMO_OF,n.totalPRCMO"; } $sql .= " FROM " . MAIN_DB_PREFIX . "assetOf_line l\n\t\tINNER JOIN " . MAIN_DB_PREFIX . "nomenclature n ON (n.rowid=l.fk_nomenclature)\n\t\tWHERE l.type='TO_MAKE' \n\t\tGROUP BY l.fk_product,l.fk_nomenclature"; $listeview = new TListviewTBS('graphCost2'); //$PDOdb->debug=true; print $listeview->render($PDOdb, $sql, array('liste' => array('titre' => $langs->transnoentitiesnoconv('RapportAnalyseCoutProductPF')), 'link' => array('fk_nomenclature' => '<a href="' . dol_buildpath('/nomenclature/nomenclature.php?fk_product=@fk_product@', 1) . '">' . img_picto($langs->trans('Nomenclature'), 'object_list') . ' @val@</a>'), 'eval' => array('fk_product' => '_product_link(@fk_product@)'), 'type' => array('qty' => 'number', 'totalPRCMO' => 'number', 'totalPRCMO_PMP' => 'number', 'totalPRCMO_OF' => 'number', 'date_maj' => 'date'), 'title' => array('fk_product' => $langs->trans('Product'), 'qty' => $langs->trans('Qty'), 'totalPRCMO' => $langs->trans('PricePA'), 'totalPRCMO_PMP' => $langs->trans('PricePMP'), 'totalPRCMO_OF' => $langs->trans('PriceOF'), 'date_maj' => $langs->trans('Date'), 'fk_nomenclature' => $langs->trans('Nomenclature')), 'search' => array('date_maj' => array('recherche' => 'calendars', 'table' => 'l')))); $formCore->end(); } if (!empty($conf->quality->enabled)) { echo '<hr />'; dol_include_once('/quality/class/quality.class.php'); $sql = "SELECT l.fk_product, q.code, q.qty, q.date_cre, q.comment\n\t\tFROM " . MAIN_DB_PREFIX . "assetOf_line l \n\t\t\tINNER JOIN " . MAIN_DB_PREFIX . "quality q ON (q.fk_object = l.rowid AND q.type_object = 'TAssetOFLine') \n\t\tWHERE l.type='NEEDED' AND q.code!='NORMAL' AND q.qty!=0\n\t\t"; $formCore = new TFormCore('auto', 'formGraph3'); $listeview = new TListviewTBS('graphCost3'); //$PDOdb->debug=true; print $listeview->render($PDOdb, $sql, array('liste' => array('titre' => $langs->transnoentitiesnoconv('RapportAnalyseMotifRebus')), 'eval' => array('fk_product' => '_product_link(@fk_product@)'), 'translate' => array('code' => TC_quality::getAll($PDOdb, true)), 'type' => array('qty' => 'number', 'date_cre' => 'date'), 'title' => array('fk_product' => $langs->trans('Product'), 'qty' => $langs->trans('Qty'), 'comment' => $langs->trans('Comment'), 'code' => $langs->trans('Code'), 'date_cre' => $langs->trans('Date')), 'search' => array('date_cre' => array('recherche' => 'calendars', 'table' => 'l')))); $formCore->end(); } dol_fiche_end(); // End of page llxFooter(); function _get_percent($qty, $qty_used) { $percent = ($qty_used - $qty) / $qty * 100; $color = ''; if ($percent > 0.5) { $color = 'red'; } else { if ($percent < -0.5) {
function liste() { global $langs, $conf, $user; $PDOdb = new TPDOdb(); llxHeader('', 'Query', '', '', 0, 0, array(), array('/query/css/query.css')); dol_fiche_head(); $sql = "SELECT rowid as 'Id', type,nb_result_max, title,expert,0 as 'delete' \n\tFROM " . MAIN_DB_PREFIX . "query\n\tWHERE 1\n\t "; $formCore = new TFormCore('auto', 'formQ', 'get'); $r = new TListviewTBS('lQuery'); echo $r->render($PDOdb, $sql, array('link' => array('Id' => '<a href="?action=view&id=@val@">' . img_picto('Edit', 'edit.png') . ' @val@</a>', 'title' => '<a href="?action=run&id=@Id@">' . img_picto('Run', 'object_cron.png') . ' @val@</a>', 'delete' => '<a href="?action=delete&id=@Id@" onclick="return(confirm(\'' . $langs->trans('ConfirmDeleteMessage') . '\'));">' . img_picto('Delete', 'delete.png') . '</a>'), 'orderBy' => array('title' => 'ASC'), 'hide' => array('type', 'nb_result_max'), 'title' => array('title' => $langs->trans('Title'), 'expert' => $langs->trans('Expert'), 'delete' => $langs->trans('Delete')), 'translate' => array('expert' => array(0 => $langs->trans('No'), 1 => $langs->trans('Yes'), 2 => $langs->trans('Free'))), 'search' => array('title' => true))); $formCore->end(); $formCore = new TFormCore('auto', 'formUPQ', 'post', true); echo $formCore->hidden('action', 'up_query'); echo $formCore->fichier($langs->trans('QueryToUpload'), 'query_to_upload', '', 10) . ' ' . $formCore->btsubmit($langs->trans('UploadQuery'), 'bt_upquery'); $formCore->end(); dol_fiche_end(); llxFooter(); }
<?php require '../config.php'; dol_include_once('/query/class/query.class.php'); $PDOdb = new TPDOdb(); $l = new TListviewTBS('list1'); llxHeader(); $sql = "SELECT rowid,login, firstname, lastname FROM " . MAIN_DB_PREFIX . "user"; echo $l->render($PDOdb, $sql, array('title' => array('firstname' => $langs->trans('Firstname')), 'hide' => array('rowid'), 'eval' => array('login' => '_get_nom(@rowid@)'))); llxFooter(); function _get_nom($fk_user) { $r = TQuery::getNomUrl("User", $fk_user); var_dump($r); return $r; }
<?php require 'config.php'; dol_include_once('/core/lib/product.lib.php'); $langs->load("other"); llxHeader('', 'Liste des expéditions à préparer', '', ''); $ATMdb = new TPDOdb(); $sql = "SELECT s.rowid as soc_id, s.nom as soc_nom, e.rowid as expe_id, e.ref as expe_ref, c.rowid as comm_id, c.ref as comm_ref, "; $sql .= "p.rowid as prod_id, CONCAT(p.ref, ' ', p.label) as prod_ref, cd.qty, cd.tarif_poids, cd.poids, cd.asset_lot "; $sql .= "FROM " . MAIN_DB_PREFIX . "expedition e "; $sql .= "LEFT JOIN " . MAIN_DB_PREFIX . "expeditiondet ed ON ed.fk_expedition = e.rowid "; //$sql.= "LEFT JOIN ".MAIN_DB_PREFIX."element_element ee ON ee.fk_target = e.rowid AND ee.targettype = 'shipping' "; //$sql.= "LEFT JOIN ".MAIN_DB_PREFIX."commande c ON ee.fk_source = c.rowid AND ee.sourcetype = 'commande' "; $sql .= "LEFT JOIN " . MAIN_DB_PREFIX . "commandedet cd ON ed.fk_origin_line = cd.rowid "; $sql .= "LEFT JOIN " . MAIN_DB_PREFIX . "commande c ON cd.fk_commande = c.rowid "; $sql .= "LEFT JOIN " . MAIN_DB_PREFIX . "product p ON cd.fk_product = p.rowid "; $sql .= "LEFT JOIN " . MAIN_DB_PREFIX . "societe s ON c.fk_soc = s.rowid "; $sql .= "WHERE e.fk_statut = 0 "; $sql .= "ORDER BY prod_ref, soc_nom"; $r = new TListviewTBS('expe'); $measuring_units = array(-9 => 1, -6 => 1, -3 => 1, 0 => 1, 3 => 1, 99 => 1, 100 => 1); foreach ($measuring_units as $key => $value) { $TPoids[$key] = measuring_units_string($key, 'weight'); } echo $r->render($ATMdb, $sql, array('limit' => array('nbLine' => '30'), 'link' => array('soc_nom' => '<a href="' . DOL_URL_ROOT . '/societe/soc.php?socid=@soc_id@">' . img_picto('', 'object_company.png', '', 0) . ' @val@</a>', 'expe_ref' => '<a href="' . DOL_URL_ROOT . '/expedition/fiche.php?id=@expe_id@">' . img_picto('', 'object_sending.png', '', 0) . ' @val@</a>', 'comm_ref' => '<a href="' . DOL_URL_ROOT . '/commande/fiche.php?id=@comm_id@">' . img_picto('', 'object_order.png', '', 0) . ' @val@</a>', 'prod_ref' => '<a href="' . DOL_URL_ROOT . '/product/fiche.php?id=@prod_id@">' . img_picto('', 'object_product.png', '', 0) . ' @val@</a>'), 'translate' => array('poids' => $TPoids), 'hide' => array('soc_id', 'expe_id', 'comm_id', 'prod_id'), 'type' => array('tarif_poids' => 'number', 'qty' => 'number'), 'liste' => array('titre' => 'Liste des expéditions à préparer', 'image' => img_picto('', 'title.png', '', 0), 'picto_precedent' => img_picto('', 'back.png', '', 0), 'picto_suivant' => img_picto('', 'next.png', '', 0), 'noheader' => (int) isset($_REQUEST['fk_soc']) | (int) isset($_REQUEST['fk_product']), 'messageNothing' => "Il n'y a aucunes expédition à afficher", 'picto_search' => img_picto('', 'search.png', '', 0)), 'title' => array('soc_nom' => 'Client', 'expe_ref' => 'Expédition', 'comm_ref' => 'Commande', 'prod_ref' => 'Produit', 'qty' => 'Quantité', 'tarif_poids' => 'Poids', 'asset_lot' => 'Lot'))); llxFooter();
} 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();
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 liste(&$db, $sql = '', $TParam = array()) { if (empty($sql)) { $sql = $this->sql; } $fields = ''; foreach ($this->TList['Fields'] as $k => $v) { $fields .= ",`{$k}` as '" . addslashes($v) . "'"; } $sql = strtr($sql, array('@Champs@' => $fields, '@table@' => $this->object->get_table())); $listname = 'list_' . $this->object->get_table(); $lst = new TListviewTBS($listname); print $lst->render($db, $sql, $TParam); }
function runList(&$PDOdb, $template = '', $table_element = '', $objectid = 0) { global $conf, $langs; $html = ''; $sql = $this->getSQL($table_element, $objectid); $TBind = $this->getBind(); $TSearch = $this->getSearch(); $THide = $this->getHide(); $TTranslate = $this->getTranslate(); $TTotal = $this->getTotal(); $TOperator = $this->getOperator(); $TType = $this->getType(); $TEval = $this->getEval(); if ($this->show_details) { $html .= '<div class="query">' . $sql . '</div>'; } $TTitle = $this->getTitle(); $r = new TListviewTBS('lRunQuery' . $this->getId(), $template); //echo 3; $html .= $r->render($PDOdb, $sql, array('link' => $this->TLink, 'no-select' => true, 'hide' => $THide, 'title' => $TTitle, 'liste' => array('titre' => ''), 'limit' => array('global' => $this->nb_result_max), 'type' => $TType, 'orderBy' => $this->TOrder, 'translate' => $TTranslate, 'search' => $TSearch, 'export' => array('CSV', 'TXT'), 'operator' => $TOperator, 'math' => $TTotal, 'eval' => $TEval), $TBind); //echo 4; if ($this->show_details) { $html .= '<div class="query">'; $Tab = array(); foreach ($r->TBind as $f => $v) { $Tab[] = $f . ' : ' . $v; } $html .= implode(', ', $Tab); $html .= '</div>'; } if ($this->type == 'CHART' || $this->type == 'LINE' || $this->type == 'PIE' || $this->type == 'AREA') { $html .= '<div class="tabsAction"> <input type="submit" class="butAction" name="show_as_graph" value="' . $langs->trans('ShowGraphNormal') . '" /> </div>'; } return $html; }
function liste($type) { global $conf, $langs; $page_name = "RemiseSetup"; llxHeader('', $langs->trans($page_name)); $linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>'; print_fiche_titre($langs->trans($page_name), $linkback); // Configuration header $head = remiseAdminPrepareHead(); dol_fiche_head($head, $type, $page_name, 0, "remise@remise"); $l = new TListviewTBS('lPrice'); $sql = "SELECT rowid as Id, palier,remise,zip,fk_shipment_mode,date_maj FROM " . MAIN_DB_PREFIX . "remise \n\t\t\tWHERE type=:type"; $PDOdb = new TPDOdb(); $form = new TFormCore('auto', 'form1', 'get'); echo $form->hidden('type', $type); echo $l->render($PDOdb, $sql, array('link' => array('Id' => '<a href="' . dol_buildpath('/remise/admin/remise.php?action=edit&id=@val@&type=' . $type, 1) . '">@val@</a>'), 'type' => array('remise' => 'money', 'palier' => 'number', 'date_maj' => 'date'), 'title' => array('palier' => $langs->trans('Palier'), 'zip' => $langs->trans('Zip'), 'fk_shipment_mode' => $langs->trans('ShipmentMode'), 'remise' => $langs->trans('Remise'), 'date_maj' => $langs->trans('Update')), 'eval' => array('fk_shipment_mode' => 'showShipmentMode(@val@)'), 'search' => array('palier' => true, 'zip' => true, 'remise' => true)), array(':type' => $type)); $form->end(); echo '<div class="tabsAction">'; echo $form->bt($langs->trans('New'), 'bt_new', ' onclick="document.location.href=\'?type=' . $type . '&action=new\' "'); echo '</div>'; dol_fiche_end(); llxFooter(); }