/** * Reconstruit l'arborescence des categories sous la forme d'un tableau * Renvoi un tableau de tableau('id','id_mere',...) trie selon arbre et avec: * id = id de la categorie * id_mere = id de la categorie mere * id_children = tableau des id enfant * label = nom de la categorie * fulllabel = nom avec chemin complet de la categorie * fullpath = chemin complet compose des id * * @param string $type Type of categories (0=product, 1=suppliers, 2=customers, 3=members) * @param int $markafterid Mark all categories after this leaf in category tree. * @return array Array of categories */ function get_full_arbo($type) { global $db, $conf; $categorie = new Categorie($db); $categorie->cats = array(); // Init $this->cats array $sql = "SELECT DISTINCT c.rowid, c.label, c.description, c.fk_parent"; // Distinct reduce pb with old tables with duplicates $sql .= " FROM " . MAIN_DB_PREFIX . "categorie as c"; $sql .= " WHERE c.entity IN (" . getEntity('category', 1) . ")"; $sql .= " AND c.type = " . $type; $sql .= " AND fk_parent = 0"; dol_syslog(get_class($categorie) . "::get_full_arbo get category list sql=" . $sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { $i = 0; while ($obj = $db->fetch_object($resql)) { $categorie->cats[$obj->rowid]['rowid'] = $obj->rowid; $categorie->cats[$obj->rowid]['id'] = $obj->rowid; $categorie->cats[$obj->rowid]['fk_parent'] = $obj->fk_parent; $categorie->cats[$obj->rowid]['label'] = $obj->label; $categorie->cats[$obj->rowid]['description'] = $obj->description; $i++; } } else { dol_print_error($db); return -1; } // We add the fullpath property to each elements of first level (no parent exists) dol_syslog(get_class($categorie) . "::get_full_arbo call to build_path_from_id_categ", LOG_DEBUG); foreach ($categorie->cats as $key => $val) { $categorie->build_path_from_id_categ($key, 0); // Process a branch from the root category key (this category has no parent) } dol_syslog(get_class($categorie) . "::get_full_arbo dol_sort_array", LOG_DEBUG); $categorie->cats = dol_sort_array($categorie->cats, 'fulllabel', 'asc', true, false); //$this->debug_cats(); return $categorie->cats; }
print '<td align="left" width="24">'; print img_picto_common('', 'treemenu/base.gif'); print '</td><td align="left">'; $txt = $langs->trans("ECMRoot") . ' (' . $langs->trans("ECMSectionsAuto") . ')'; print $form->textwithpicto($txt, $htmltooltip, 1, 0); print '</td>'; print '</tr></table>'; print '</td>'; print '<td align="right"> </td>'; print '<td align="right"> </td>'; print '<td align="right"> </td>'; print '<td align="right"> </td>'; print '<td align="center">'; print '</td>'; print '</tr>'; $sectionauto = dol_sort_array($sectionauto, 'label', 'ASC', true, false); print '<tr>'; print '<td colspan="6" style="padding-left: 20px">'; print '<div id="filetreeauto" class="ecmfiletree"><ul class="ecmjqft">'; $nbofentries = 0; $oldvallevel = 0; foreach ($sectionauto as $key => $val) { if (empty($val['test'])) { continue; } // If condition to show is ok $var = false; print '<li class="directory collapsed">'; if (!empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE_JS)) { print '<a class="fmdirlia jqft ecmjqft" href="' . $_SERVER["PHP_SELF"] . '?module=' . $val['module'] . '">'; print $val['label'];
/** * Reconstruit l'arborescence hierarchique des users sous la forme d'un tableau * Set and return this->users that is an array sorted according to tree with arrays of: * id = id user * lastname * firstname * fullname = nom avec chemin complet du user * fullpath = chemin complet compose des id: "_grandparentid_parentid_id" * * @param int $deleteafterid Removed all users including the leaf $deleteafterid (and all its child) in user tree. * @param string $filter SQL filter on users * @return array Array of users $this->users. Note: $this->parentof is also set. */ function get_full_tree($deleteafterid = 0, $filter = '') { global $conf, $user; $this->users = array(); // Init this->parentof that is array(id_son=>id_parent, ...) $this->load_parentof(); // Init $this->users array $sql = "SELECT DISTINCT u.rowid, u.firstname, u.lastname, u.fk_user, u.fk_soc, u.login, u.email, u.gender, u.admin, u.statut, u.photo, u.entity"; // Distinct reduce pb with old tables with duplicates $sql .= " FROM " . MAIN_DB_PREFIX . "user as u"; if (!empty($conf->multicompany->enabled) && $conf->entity == 1 && (!empty($conf->multicompany->transverse_mode) || !empty($user->admin) && empty($user->entity))) { $sql .= " WHERE u.entity IS NOT NULL"; } else { $sql .= " WHERE u.entity IN (" . getEntity('user', 1) . ")"; } if ($filter) { $sql .= " AND " . $filter; } dol_syslog(get_class($this) . "::get_full_tree get user list", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $i = 0; while ($obj = $this->db->fetch_object($resql)) { $this->users[$obj->rowid]['rowid'] = $obj->rowid; $this->users[$obj->rowid]['id'] = $obj->rowid; $this->users[$obj->rowid]['fk_user'] = $obj->fk_user; $this->users[$obj->rowid]['fk_soc'] = $obj->fk_soc; $this->users[$obj->rowid]['firstname'] = $obj->firstname; $this->users[$obj->rowid]['lastname'] = $obj->lastname; $this->users[$obj->rowid]['login'] = $obj->login; $this->users[$obj->rowid]['statut'] = $obj->statut; $this->users[$obj->rowid]['entity'] = $obj->entity; $this->users[$obj->rowid]['email'] = $obj->email; $this->users[$obj->rowid]['gender'] = $obj->gender; $this->users[$obj->rowid]['admin'] = $obj->admin; $this->users[$obj->rowid]['photo'] = $obj->photo; $i++; } } else { dol_print_error($this->db); return -1; } // We add the fullpath property to each elements of first level (no parent exists) dol_syslog(get_class($this) . "::get_full_tree call to build_path_from_id_user", LOG_DEBUG); foreach ($this->users as $key => $val) { $this->build_path_from_id_user($key, 0); // Process a branch from the root user key (this user has no parent) } // Exclude leaf including $deleteafterid from tree if ($deleteafterid) { //print "Look to discard user ".$deleteafterid."\n"; $keyfilter1 = '^' . $deleteafterid . '$'; $keyfilter2 = '_' . $deleteafterid . '$'; $keyfilter3 = '^' . $deleteafterid . '_'; $keyfilter4 = '_' . $deleteafterid . '_'; foreach ($this->users as $key => $val) { if (preg_match('/' . $keyfilter1 . '/', $val['fullpath']) || preg_match('/' . $keyfilter2 . '/', $val['fullpath']) || preg_match('/' . $keyfilter3 . '/', $val['fullpath']) || preg_match('/' . $keyfilter4 . '/', $val['fullpath'])) { unset($this->users[$key]); } } } dol_syslog(get_class($this) . "::get_full_tree dol_sort_array", LOG_DEBUG); $this->users = dol_sort_array($this->users, 'fullname', 'asc', true, false); //var_dump($this->users); return $this->users; }
/** * Reconstruit l'arborescence des categories sous la forme d'un tableau * Renvoi un tableau de tableau('id','id_mere',...) trie selon arbre et avec: * id Id de la categorie * id_mere Id de la categorie mere * id_children Tableau des id enfant * label Name of directory * cachenbofdoc Nb of documents * date_c Date creation * fk_user_c User creation * login_c Login creation * fullpath Full path of id (Added by build_path_from_id_categ call) * fullrelativename Full path name (Added by build_path_from_id_categ call) * fulllabel Full label (Added by build_path_from_id_categ call) * level Level of line (Added by build_path_from_id_categ call) * * @param int $force Force reload of full arbo even if already loaded in cache $this->cats * @return array Tableau de array */ function get_full_arbo($force = 0) { global $conf; if (empty($force) && !empty($this->full_arbo_loaded)) { return $this->cats; } // Init this->motherof that is array(id_son=>id_parent, ...) $this->load_motherof(); // Charge tableau des categories $sql = "SELECT c.rowid as rowid, c.label as label,"; $sql .= " c.description as description, c.cachenbofdoc,"; $sql .= " c.fk_user_c,"; $sql .= " c.date_c,"; $sql .= " u.login as login_c,"; $sql .= " ca.rowid as rowid_fille"; $sql .= " FROM " . MAIN_DB_PREFIX . "user as u, " . MAIN_DB_PREFIX . "ecm_directories as c"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "ecm_directories as ca"; $sql .= " ON c.rowid = ca.fk_parent"; $sql .= " WHERE c.fk_user_c = u.rowid"; $sql .= " AND c.entity = " . $conf->entity; $sql .= " ORDER BY c.label, c.rowid"; dol_syslog(get_class($this) . "::get_full_arbo sql=" . $sql); $resql = $this->db->query($sql); if ($resql) { $this->cats = array(); $i = 0; // This assignment in condition is not a bug. It allows walking the results. while ($obj = $this->db->fetch_object($resql)) { $this->cats[$obj->rowid]['id'] = $obj->rowid; $this->cats[$obj->rowid]['id_mere'] = isset($this->motherof[$obj->rowid]) ? $this->motherof[$obj->rowid] : ''; $this->cats[$obj->rowid]['label'] = $obj->label; $this->cats[$obj->rowid]['description'] = $obj->description; $this->cats[$obj->rowid]['cachenbofdoc'] = $obj->cachenbofdoc; $this->cats[$obj->rowid]['date_c'] = $this->db->jdate($obj->date_c); $this->cats[$obj->rowid]['fk_user_c'] = $obj->fk_user_c; $this->cats[$obj->rowid]['login_c'] = $obj->login_c; if (!empty($obj->rowid_fille)) { if (isset($this->cats[$obj->rowid]['id_children']) && is_array($this->cats[$obj->rowid]['id_children'])) { $newelempos = count($this->cats[$obj->rowid]['id_children']); //print "this->cats[$i]['id_children'] est deja un tableau de $newelem elements<br>"; $this->cats[$obj->rowid]['id_children'][$newelempos] = $obj->rowid_fille; } else { //print "this->cats[".$obj->rowid."]['id_children'] n'est pas encore un tableau<br>"; $this->cats[$obj->rowid]['id_children'] = array($obj->rowid_fille); } } $i++; } } else { dol_print_error($this->db); return -1; } // We add properties fullxxx to all elements foreach ($this->cats as $key => $val) { if (isset($motherof[$key])) { continue; } $this->build_path_from_id_categ($key, 0); } $this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false); $this->full_arbo_loaded = 1; return $this->cats; }
/** * Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne. * Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays * * @param string $selected Preselected code of juridical type * @param int $country_codeid 0=list for all countries, otherwise list only country requested * @param string $filter Add a SQL filter on list * @return string String with HTML select */ function select_juridicalstatus($selected = '', $country_codeid = 0, $filter = '') { global $conf, $langs, $user; $langs->load("dict"); $out = ''; // On recherche les formes juridiques actives des pays actifs $sql = "SELECT f.rowid, f.code as code , f.libelle as label, f.active, c.label as country, c.code as country_code"; $sql .= " FROM " . MAIN_DB_PREFIX . "c_forme_juridique as f, " . MAIN_DB_PREFIX . "c_country as c"; $sql .= " WHERE f.fk_pays=c.rowid"; $sql .= " AND f.active = 1 AND c.active = 1"; if ($country_codeid) { $sql .= " AND c.code = '" . $country_codeid . "'"; } if ($filter) { $sql .= " " . $filter; } $sql .= " ORDER BY c.code"; dol_syslog(get_class($this) . "::select_juridicalstatus", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $out .= '<div id="particulier2" class="visible">'; $out .= '<select class="flat" name="forme_juridique_code" id="legal_form">'; if ($country_codeid) { $out .= '<option value="0"> </option>'; } $num = $this->db->num_rows($resql); if ($num) { $i = 0; $country = ''; $arraydata = array(); while ($i < $num) { $obj = $this->db->fetch_object($resql); $labelcountry = $langs->trans("Country" . $obj->country_code) != "Country" . $obj->country_code ? $langs->trans("Country" . $obj->country_code) : $obj->country; $labeljs = $langs->trans("JuridicalStatus" . $obj->code) != "JuridicalStatus" . $obj->code ? $langs->trans("JuridicalStatus" . $obj->code) : ($obj->label != '-' ? $obj->label : ''); // $obj->label is already in output charset (converted by database driver) $arraydata[$obj->code] = array('code' => $obj->code, 'label' => $labeljs, 'label_sort' => $labelcountry . '_' . $labeljs, 'country_code' => $obj->country_code, 'country' => $labelcountry); $i++; } $arraydata = dol_sort_array($arraydata, 'label_sort', 'ASC'); foreach ($arraydata as $key => $val) { if (!$country || $country != $val['country']) { // Show break when we are in multi country mode if (empty($country_codeid) && $val['country_code']) { $out .= '<option value="0">----- ' . $val['country'] . " -----</option>\n"; $country = $val['country']; } } if ($selected > 0 && $selected == $val['code']) { $out .= '<option value="' . $val['code'] . '" selected="selected">'; } else { $out .= '<option value="' . $val['code'] . '">'; } // If translation exists, we use it, otherwise we use default label in database $out .= $val['label']; $out .= '</option>'; } } $out .= '</select>'; if ($user->admin) { $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); } $out .= '</div>'; } else { dol_print_error($this->db); } return $out; }
/** * Reconstruit l'arborescence des categories sous la forme d'un tableau * Renvoi un tableau de tableau('id','id_mere',...) trie selon arbre et avec: * id = id de la categorie * id_mere = id de la categorie mere * id_children = tableau des id enfant * label = nom de la categorie * fulllabel = nom avec chemin complet de la categorie * fullpath = chemin complet compose des id * * @param string $type Type of categories (0=product, 1=suppliers, 2=customers, 3=members) * @param int $markafterid Mark all categories after this leaf in category tree. * @return array Array of categories */ function get_full_arbo($type, $markafterid = 0) { $this->cats = array(); // Charge tableau des meres $sql = "SELECT ca.fk_categorie_mere as id_mere, ca.fk_categorie_fille as id_fille"; $sql .= " FROM " . MAIN_DB_PREFIX . "categorie_association ca"; $sql .= ", " . MAIN_DB_PREFIX . "categorie as c"; $sql .= " WHERE ca.fk_categorie_mere = c.rowid"; $sql .= " AND c.entity IN (" . getEntity('category', 1) . ")"; // Load array this->motherof dol_syslog("Categorie::get_full_arbo build motherof array sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { while ($obj = $this->db->fetch_object($resql)) { $this->motherof[$obj->id_fille] = $obj->id_mere; } } else { dol_print_error($this->db); return -1; } // Init $this->cats array $sql = "SELECT DISTINCT c.rowid, c.label as label, ca.fk_categorie_fille as rowid_fille, c.priority"; // Distinct reduce pb with old tables with duplicates $sql .= " FROM " . MAIN_DB_PREFIX . "categorie as c"; $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "categorie_association as ca"; $sql .= " ON c.rowid = ca.fk_categorie_mere"; $sql .= " WHERE c.type = " . $type; $sql .= " AND c.entity IN (" . getEntity('category', 1) . ")"; $sql .= " ORDER BY c.label, c.rowid"; dol_syslog("Categorie::get_full_arbo get category list sql=" . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $i = 0; while ($obj = $this->db->fetch_object($resql)) { $this->cats[$obj->rowid]['id'] = $obj->rowid; if (isset($this->motherof[$obj->rowid])) { $this->cats[$obj->rowid]['id_mere'] = $this->motherof[$obj->rowid]; } $this->cats[$obj->rowid]['label'] = $obj->label; $this->cats[$obj->rowid]['priority'] = $obj->priority; if ($obj->rowid_fille) { $this->cats[$obj->rowid]['id_children'][] = $obj->rowid_fille; } $i++; } } else { dol_print_error($this->db); return -1; } // We add the fullpath property to each elements of first level (no parent exists) dol_syslog("Categorie::get_full_arbo call to build_path_from_id_categ", LOG_DEBUG); foreach ($this->cats as $key => $val) { if (isset($this->motherof[$key])) { continue; } $this->build_path_from_id_categ($key, 0); // Process a branch from the root category key (this category has no parent) } // Exclude tree for $markafterid if ($markafterid) { //print "Look to discard category ".$markafterid."\n"; $keyfilter1 = '^' . $markafterid . '$'; $keyfilter2 = '_' . $markafterid . '$'; $keyfilter3 = '^' . $markafterid . '_'; $keyfilter4 = '_' . $markafterid . '_'; foreach ($this->cats as $key => $val) { if (preg_match('/' . $keyfilter1 . '/', $val['fullpath']) || preg_match('/' . $keyfilter2 . '/', $val['fullpath']) || preg_match('/' . $keyfilter3 . '/', $val['fullpath']) || preg_match('/' . $keyfilter4 . '/', $val['fullpath'])) { //print "Categ discarded ".$this->cats[$key]['fullpath']."\n"; //$this->cats[$key]['marked']=1; unset($this->cats[$key]); } } } dol_syslog("Categorie::get_full_arbo dol_sort_array", LOG_DEBUG); $this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false); //$this->debug_cats(); return $this->cats; }
'id'=>'4256,4255', // Put of list of sparkangels widget id (for each language) 'lang'=>'fr,en'), // Put list of language code of widgets (always english at end) // Widget for Regis Houssin array('name'=>'Régis Houssin', 'sort'=>2, 'logo'=>'logoUrl='.urlencode('http://www.cap-networks.com/images/logo_small.jpg'), 'id'=>'5391', 'lang'=>'fr'), // Widget for Auguria array('name'=>'Auguria', 'sort'=>2, //'logo'=>'logoUrl='.urlencode('http://www.cap-networks.com/images/logo_small.jpg'), 'id'=>'7196', 'lang'=>'fr') ); $arrayofwidgets=dol_sort_array($arrayofwidgets,'sort','asc',0,0); $found=0; print '* '.$langs->trans("LinkToGoldMember",$langs->defaultlang).'<br><br>'; print '<table summary="listofgoldcoaches"><tr>'; foreach ($arrayofwidgets as $arraywidget) // Loop on each user { if ($found >= $limit) break; $listofwidgets=explode(',',$arraywidget['id']); $listoflangs=explode(',',$arraywidget['lang']); $pos=0; foreach($listoflangs as $langcode) // Loop on each lang of user { $pos++; if (preg_match('/'.$langcode.'/i',$langs->defaultlang) || $langcode == 'en') // If lang qualified {
} } else { print '<tr ' . $bc[false] . '><td colspan="2">' . $langs->trans("None") . '</td></tr>'; } print '</table>'; print '<br>'; print '<table class="noborder">'; print '<tr class="liste_titre">'; print '<td>' . $langs->trans("FilesUpdated") . '</td>'; print '<td align="center">' . $langs->trans("ExpectedChecksum") . '</td>'; print '<td align="center">' . $langs->trans("CurrentChecksum") . '</td>'; print '<td align="right">' . $langs->trans("Size") . '</td>'; print '<td align="right">' . $langs->trans("DateModification") . '</td>'; print '</tr>' . "\n"; $var = true; $tmpfilelist = dol_sort_array($file_list['updated'], 'filename'); if (is_array($tmpfilelist) && count($tmpfilelist)) { foreach ($tmpfilelist as $file) { $var = !$var; print '<tr ' . $bc[$var] . '>'; print '<td>' . $file['filename'] . '</td>' . "\n"; print '<td align="center">' . $file['expectedmd5'] . '</td>' . "\n"; print '<td align="center">' . $file['md5'] . '</td>' . "\n"; print '<td align="right">' . dol_print_size(dol_filesize(DOL_DOCUMENT_ROOT . '/' . $file['filename'])) . '</td>' . "\n"; print '<td align="right">' . dol_print_date(dol_filemtime(DOL_DOCUMENT_ROOT . '/' . $file['filename']), 'dayhour') . '</td>' . "\n"; print "</tr>\n"; } } else { print '<tr ' . $bc[false] . '><td colspan="5">' . $langs->trans("None") . '</td></tr>'; } print '</table>';
/** * Reconstruit l'arborescence des categories sous la forme d'un tableau * Renvoi un tableau de tableau('id','id_mere',...) trie selon arbre et avec: * id = id de la categorie * id_mere = id de la categorie mere * id_children = tableau des id enfant * label = nom de la categorie * fulllabel = nom avec chemin complet de la categorie * fullpath = chemin complet compose des id * * @param string $type Type of categories ('customer', 'supplier', 'contact', 'product', 'member'). * Old mode (0, 1, 2, ...) is deprecated. * @param int $markafterid Removed all categories including the leaf $markafterid in category tree. * * @return array Array of categories. this->cats and this->motherof are set. */ function get_full_arbo($type, $markafterid = 0) { global $conf, $langs; // For backward compatibility if (is_numeric($type)) { // We want to reverse lookup $map_type = array_flip($this->MAP_ID); $type = $map_type[$type]; dol_syslog(get_class($this) . "::get_full_arbo(): numeric types are deprecated, please use string instead", LOG_WARNING); } $this->cats = array(); // Init this->motherof that is array(id_son=>id_parent, ...) $this->load_motherof(); $current_lang = $langs->getDefaultLang(); // Init $this->cats array $sql = "SELECT DISTINCT c.rowid, c.label, c.description, c.fk_parent"; // Distinct reduce pb with old tables with duplicates if (!empty($conf->global->MAIN_MULTILANGS)) { $sql .= ", t.label as label_trans, t.description as description_trans"; } $sql .= " FROM " . MAIN_DB_PREFIX . "categorie as c"; if (!empty($conf->global->MAIN_MULTILANGS)) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "categorie_lang as t ON t.fk_category=c.rowid AND t.lang='" . $current_lang . "'"; } $sql .= " WHERE c.entity IN (" . getEntity('category', 1) . ")"; $sql .= " AND c.type = " . $this->MAP_ID[$type]; dol_syslog(get_class($this) . "::get_full_arbo get category list", LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $i = 0; while ($obj = $this->db->fetch_object($resql)) { $this->cats[$obj->rowid]['rowid'] = $obj->rowid; $this->cats[$obj->rowid]['id'] = $obj->rowid; $this->cats[$obj->rowid]['fk_parent'] = $obj->fk_parent; $this->cats[$obj->rowid]['label'] = !empty($obj->label_trans) ? $obj->label_trans : $obj->label; $this->cats[$obj->rowid]['description'] = !empty($obj->description_trans) ? $obj->description_trans : $obj->description; $i++; } } else { dol_print_error($this->db); return -1; } // We add the fullpath property to each elements of first level (no parent exists) dol_syslog(get_class($this) . "::get_full_arbo call to build_path_from_id_categ", LOG_DEBUG); foreach ($this->cats as $key => $val) { //print 'key='.$key.'<br>'."\n"; $this->build_path_from_id_categ($key, 0); // Process a branch from the root category key (this category has no parent) } // Exclude leaf including $markafterid from tree if ($markafterid) { //print "Look to discard category ".$markafterid."\n"; $keyfilter1 = '^' . $markafterid . '$'; $keyfilter2 = '_' . $markafterid . '$'; $keyfilter3 = '^' . $markafterid . '_'; $keyfilter4 = '_' . $markafterid . '_'; foreach ($this->cats as $key => $val) { if (preg_match('/' . $keyfilter1 . '/', $val['fullpath']) || preg_match('/' . $keyfilter2 . '/', $val['fullpath']) || preg_match('/' . $keyfilter3 . '/', $val['fullpath']) || preg_match('/' . $keyfilter4 . '/', $val['fullpath'])) { unset($this->cats[$key]); } } } dol_syslog(get_class($this) . "::get_full_arbo dol_sort_array", LOG_DEBUG); $this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false); //$this->debug_cats(); return $this->cats; }
/** * Load into cache cache_demand_reason, array of input reasons * @return int Nb of lines loaded, 0 if already loaded, <0 if ko */ function load_cache_demand_reason() { global $langs; if (sizeof($this->cache_demand_reason)) { return 0; } // Cache already loaded $sql = "SELECT rowid, code, label"; $sql .= " FROM " . MAIN_DB_PREFIX . 'c_input_reason'; $sql .= " WHERE active=1"; $sql .= " ORDER BY rowid"; dol_syslog('Form::load_cache_demand_reason sql=' . $sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); $i = 0; $tmparray = array(); while ($i < $num) { $obj = $this->db->fetch_object($resql); // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut $label = $langs->trans("DemandReasonType" . $obj->code) != "DemandReasonType" . $obj->code ? $langs->trans("DemandReasonType" . $obj->code) : ($obj->label != '-' ? $obj->label : ''); $tmparray[$obj->rowid]['id'] = $obj->rowid; $tmparray[$obj->rowid]['code'] = $obj->code; $tmparray[$obj->rowid]['label'] = $label; $i++; } $this->cache_demand_reason = dol_sort_array($tmparray, 'label', $order = 'asc', $natsort, $case_sensitive); unset($tmparray); return 1; } else { dol_print_error($this->db); return -1; } }
/** * Charge dans cache la liste des types de paiements possibles * * @return int Nb of lines loaded, <0 if KO */ function load_cache_types_paiements() { global $langs; $num = count($this->cache_types_paiements); if ($num > 0) { return $num; } // Cache already loaded dol_syslog(__METHOD__, LOG_DEBUG); $this->cache_types_paiements = array(); $sql = "SELECT id, code, libelle as label, type, active"; $sql .= " FROM " . MAIN_DB_PREFIX . "c_paiement"; //if ($active >= 0) $sql.= " WHERE active = ".$active; $resql = $this->db->query($sql); if ($resql) { $num = $this->db->num_rows($resql); $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut $label = $langs->transnoentitiesnoconv("PaymentTypeShort" . $obj->code) != "PaymentTypeShort" . $obj->code ? $langs->transnoentitiesnoconv("PaymentTypeShort" . $obj->code) : ($obj->label != '-' ? $obj->label : ''); $this->cache_types_paiements[$obj->id]['id'] = $obj->id; $this->cache_types_paiements[$obj->id]['code'] = $obj->code; $this->cache_types_paiements[$obj->id]['label'] = $label; $this->cache_types_paiements[$obj->id]['type'] = $obj->type; $this->cache_types_paiements[$obj->id]['active'] = $obj->active; $i++; } $this->cache_types_paiements = dol_sort_array($this->cache_types_paiements, 'label', 'asc', 0, 0, 1); return $num; } else { dol_print_error($this->db); return -1; } }