本文整理汇总了PHP中DoliDB::fetch_object方法的典型用法代码示例。如果您正苦于以下问题:PHP DoliDB::fetch_object方法的具体用法?PHP DoliDB::fetch_object怎么用?PHP DoliDB::fetch_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoliDB
的用法示例。
在下文中一共展示了DoliDB::fetch_object方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pt
/**
* pt
*
* @param DoliDB $db Database handler
* @param string $sql SQL Request
* @param string $date Date
* @return void
*/
function pt($db, $sql, $date)
{
global $conf, $bc, $langs;
$result = $db->query($sql);
if ($result) {
$num = $db->num_rows($result);
$i = 0;
$total = 0;
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td class="nowrap" width="60%">' . $date . '</td>';
print '<td align="right">' . $langs->trans("Amount") . '</td>';
print '<td> </td>' . "\n";
print "</tr>\n";
$var = True;
while ($i < $num) {
$obj = $db->fetch_object($result);
$var = !$var;
print '<tr ' . $bc[$var] . '>';
print '<td class="nowrap">' . $obj->dm . "</td>\n";
$total = $total + $obj->mm;
print '<td class="nowrap" align="right">' . price($obj->mm) . "</td><td > </td>\n";
print "</tr>\n";
$i++;
}
print '<tr class="liste_total"><td align="right">' . $langs->trans("Total") . " :</td><td class=\"nowrap\" align=\"right\"><b>" . price($total) . "</b></td><td> </td></tr>";
print "</table>";
$db->free($result);
} else {
dol_print_error($db);
}
}
示例2: assign_post
/**
* Assign POST values into object
*
* @return string HTML output
*/
private function assign_post()
{
global $langs, $mysoc;
$this->object->old_name = $_POST["old_name"];
$this->object->old_firstname = $_POST["old_firstname"];
$this->object->fk_soc = $_POST["fk_soc"];
$this->object->lastname = $_POST["lastname"];
$this->object->firstname = $_POST["firstname"];
$this->object->civility_id = $_POST["civility_id"];
$this->object->address = $_POST["address"];
$this->object->zip = $_POST["zipcode"];
$this->object->town = $_POST["town"];
$this->object->country_id = $_POST["country_id"] ? $_POST["country_id"] : $mysoc->country_id;
$this->object->state_id = $_POST["state_id"];
$this->object->phone_perso = $_POST["phone_perso"];
$this->object->phone_mobile = $_POST["phone_mobile"];
$this->object->email = $_POST["email"];
$this->object->note = $_POST["note"];
$this->object->canvas = $_POST["canvas"];
// We set country_id, and country_code label of the chosen country
if ($this->object->country_id) {
$sql = "SELECT code, label FROM " . MAIN_DB_PREFIX . "c_country WHERE rowid = " . $this->object->country_id;
$resql = $this->db->query($sql);
if ($resql) {
$obj = $this->db->fetch_object($resql);
} else {
dol_print_error($this->db);
}
$this->object->country_code = $obj->code;
$this->object->country = $langs->trans("Country" . $obj->code) ? $langs->trans("Country" . $obj->code) : $obj->libelle;
}
}
示例3: print_left_eldy_menu
//.........这里部分代码省略.........
if (empty($leftmenu) || preg_match('/report/', $leftmenu)) {
$newmenu->add("/compta/journal/sellsjournal.php?leftmenu=report", $langs->trans("SellsJournal"), 1, $user->rights->compta->resultat->lire);
}
if (empty($leftmenu) || preg_match('/report/', $leftmenu)) {
$newmenu->add("/compta/journal/purchasesjournal.php?leftmenu=report", $langs->trans("PurchasesJournal"), 1, $user->rights->compta->resultat->lire);
}
}
// Report expert
if (!empty($conf->accounting->enabled)) {
$langs->load("accountancy");
// Grand livre
$newmenu->add("/accountancy/bookkeeping/list.php?leftmenu=bookkeeping", $langs->trans("Bookkeeping"), 0, $user->rights->accounting->mouvements->lire, '', $mainmenu, 'bookkeeping');
if (empty($leftmenu) || preg_match('/bookkeeping/', $leftmenu)) {
$newmenu->add("/accountancy/bookkeeping/listbyyear.php", $langs->trans("ByYear"), 1, $user->rights->accounting->mouvements->lire);
}
if (empty($leftmenu) || preg_match('/bookkeeping/', $leftmenu)) {
$newmenu->add("/accountancy/bookkeeping/balancebymonth.php", $langs->trans("AccountBalanceByMonth"), 1, $user->rights->accounting->mouvements->lire);
}
// Accountancy journals
if (!empty($conf->accounting->enabled) && !empty($user->rights->accounting->mouvements->lire) && $mainmenu == 'accountancy') {
$newmenu->add('/accountancy/journal/index.php?leftmenu=journal', $langs->trans("Journaux"), 0, $user->rights->banque->lire);
if ($leftmenu == 'journal') {
$sql = "SELECT rowid, label, accountancy_journal";
$sql .= " FROM " . MAIN_DB_PREFIX . "bank_account";
$sql .= " WHERE entity = " . $conf->entity;
$sql .= " AND clos = 0";
$sql .= " ORDER BY label";
$resql = $db->query($sql);
if ($resql) {
$numr = $db->num_rows($resql);
$i = 0;
if ($numr > 0) {
while ($i < $numr) {
$objp = $db->fetch_object($resql);
$newmenu->add('/accountancy/journal/bankjournal.php?id_account=' . $objp->rowid, $langs->trans("Journal") . ' - ' . $objp->label, 1, $user->rights->accounting->comptarapport->lire);
$i++;
}
}
} else {
dol_print_error($db);
}
$db->free($resql);
// Add other journal
$newmenu->add("/accountancy/journal/sellsjournal.php?leftmenu=journal", $langs->trans("SellsJournal"), 1, $user->rights->accounting->comptarapport->lire);
$newmenu->add("/accountancy/journal/purchasesjournal.php?leftmenu=journal", $langs->trans("PurchasesJournal"), 1, $user->rights->accounting->comptarapport->lire);
}
}
}
}
// Setup
if (!empty($conf->accounting->enabled)) {
$newmenu->add("/accountancy/admin/fiscalyear.php?mainmenu=accountancy", $langs->trans("Fiscalyear"), 0, $user->rights->accounting->fiscalyear, '', $mainmenu, 'fiscalyear');
$newmenu->add("/accountancy/admin/account.php?mainmenu=accountancy", $langs->trans("Chartofaccounts"), 0, $user->rights->accounting->chartofaccount, '', $mainmenu, 'chartofaccount');
}
}
/*
* Menu BANK
*/
if ($mainmenu == 'bank') {
$langs->load("withdrawals");
$langs->load("banks");
$langs->load("bills");
// Bank-Caisse
if (!empty($conf->banque->enabled)) {
$newmenu->add("/compta/bank/index.php?leftmenu=bank&mainmenu=bank", $langs->trans("MenuBankCash"), 0, $user->rights->banque->lire, '', $mainmenu, 'bank');
$newmenu->add("/compta/bank/card.php?action=create", $langs->trans("MenuNewFinancialAccount"), 1, $user->rights->banque->configurer);
示例4: print_projecttasks_array
/**
* Return HTML table with list of projects and number of opened tasks
*
* @param DoliDB $db Database handler
* @param Form $form Object form
* @param int $socid Id thirdparty
* @param int $projectsListId Id of project i have permission on
* @param int $mytasks Limited to task i am contact to
* @param int $statut -1=No filter on statut, 0 or 1 = Filter on status
* @param array $listofoppstatus List of opportunity status
* @return void
*/
function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks = 0, $statut = -1, $listofoppstatus = array())
{
global $langs, $conf, $user, $bc;
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
$projectstatic = new Project($db);
$sortfield = '';
$sortorder = '';
$project_year_filter = 0;
$title = $langs->trans("Projects");
if (strcmp($statut, '') && $statut >= 0) {
$title = $langs->trans("Projects") . ' ' . $langs->trans($projectstatic->statuts_long[$statut]);
}
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($title, "index.php", "", "", "", "", $sortfield, $sortorder);
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
print_liste_field_titre($langs->trans("OpportunityAmount"), "", "", "", "", 'align="right"', $sortfield, $sortorder);
print_liste_field_titre($langs->trans("OpportunityStatus"), "", "", "", "", 'align="right"', $sortfield, $sortorder);
}
if (empty($conf->global->PROJECT_HIDE_TASKS)) {
print_liste_field_titre($langs->trans("Tasks"), "", "", "", "", 'align="right"', $sortfield, $sortorder);
}
print_liste_field_titre($langs->trans("Status"), "", "", "", "", 'align="right"', $sortfield, $sortorder);
print "</tr>\n";
$sql = "SELECT p.rowid as projectid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut as status, p.fk_opp_status as opp_status, p.opp_amount, COUNT(DISTINCT t.rowid) as nb";
// We use DISTINCT here because line can be doubled if task has 2 links to same user
$sql .= " FROM " . MAIN_DB_PREFIX . "projet as p";
if ($mytasks) {
$sql .= ", " . MAIN_DB_PREFIX . "projet_task as t";
$sql .= ", " . MAIN_DB_PREFIX . "element_contact as ec";
$sql .= ", " . MAIN_DB_PREFIX . "c_type_contact as ctc";
} else {
$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "projet_task as t ON p.rowid = t.fk_projet";
}
$sql .= " WHERE p.entity = " . $conf->entity;
$sql .= " AND p.rowid IN (" . $projectsListId . ")";
if ($socid) {
$sql .= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = " . $socid . ")";
}
if ($mytasks) {
$sql .= " AND p.rowid = t.fk_projet";
$sql .= " AND ec.element_id = t.rowid";
$sql .= " AND ctc.rowid = ec.fk_c_type_contact";
$sql .= " AND ctc.element = 'project_task'";
$sql .= " AND ec.fk_socpeople = " . $user->id;
}
if ($statut >= 0) {
$sql .= " AND p.fk_statut = " . $statut;
}
if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
$project_year_filter = GETPOST("project_year_filter");
//Check if empty or invalid year. Wildcard ignores the sql check
if ($project_year_filter != "*") {
if (empty($project_year_filter) || !ctype_digit($project_year_filter)) {
$project_year_filter = date("Y");
}
$sql .= " AND (p.dateo IS NULL OR p.dateo <= " . $db->idate(dol_get_last_day($project_year_filter, 12, false)) . ")";
$sql .= " AND (p.datee IS NULL OR p.datee >= " . $db->idate(dol_get_first_day($project_year_filter, 1, false)) . ")";
}
}
$sql .= " GROUP BY p.rowid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut, p.fk_opp_status, p.opp_amount";
$sql .= " ORDER BY p.title, p.ref";
$var = true;
$resql = $db->query($sql);
if ($resql) {
$total_task = 0;
$total_opp_amount = 0;
$ponderated_opp_amount = 0;
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
$objp = $db->fetch_object($resql);
$projectstatic->id = $objp->projectid;
$projectstatic->user_author_id = $objp->fk_user_creat;
$projectstatic->public = $objp->public;
// Check is user has read permission on project
$userAccess = $projectstatic->restrictedProjectArea($user);
if ($userAccess >= 0) {
$var = !$var;
print "<tr " . $bc[$var] . ">";
print '<td class="nowrap">';
$projectstatic->ref = $objp->ref;
print $projectstatic->getNomUrl(1);
print ' - ' . dol_trunc($objp->title, 24) . '</td>';
if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
print '<td align="right">';
if ($objp->opp_amount) {
print price($objp->opp_amount, 0, '', 1, -1, -1, $conf->currency);
//.........这里部分代码省略.........
示例5: vat_by_thirdparty
//.........这里部分代码省略.........
// Define sql request
$sql = '';
if ($modetax == 1) {
// If vat paid on due invoices (non draft)
if ($conf->global->MAIN_MODULE_ACCOUNTING) {
// TODO a ce jour on se sait pas la compter car le montant tva d'un payment
// n'est pas stocke dans la table des payments.
// Seul le module compta expert peut resoudre ce probleme.
// (Il faut quand un payment a lieu, stocker en plus du montant du paiement le
// detail part tva et part ht).
$sql = 'TODO';
}
if ($conf->global->MAIN_MODULE_COMPTABILITE) {
$sql = "SELECT s.rowid as socid, s.nom as nom, s.siren as tva_intra, s.tva_assuj as assuj,";
$sql .= " sum(fd.total_ht) as amount, sum(fd." . $total_tva . ") as tva,";
$sql .= " sum(fd." . $total_localtax1 . ") as localtax1,";
$sql .= " sum(fd." . $total_localtax2 . ") as localtax2";
$sql .= " FROM " . MAIN_DB_PREFIX . $invoicetable . " as f,";
$sql .= " " . MAIN_DB_PREFIX . $invoicedettable . " as fd,";
$sql .= " " . MAIN_DB_PREFIX . "societe as s";
$sql .= " WHERE f.entity = " . $conf->entity;
$sql .= " AND f.fk_statut in (1,2)";
// Validated or paid (partially or completely)
if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
$sql .= " AND f.type IN (0,1,2)";
} else {
$sql .= " AND f.type IN (0,1,2,3)";
}
if ($y && $m) {
$sql .= " AND f.datef >= '" . $db->idate(dol_get_first_day($y, $m, false)) . "'";
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, $m, false)) . "'";
} else {
if ($y) {
$sql .= " AND f.datef >= '" . $db->idate(dol_get_first_day($y, 1, false)) . "'";
$sql .= " AND f.datef <= '" . $db->idate(dol_get_last_day($y, 12, false)) . "'";
}
}
if ($date_start && $date_end) {
$sql .= " AND f.datef >= '" . $db->idate($date_start) . "' AND f.datef <= '" . $db->idate($date_end) . "'";
}
$sql .= " AND s.rowid = f.fk_soc AND f.rowid = fd." . $fk_facture;
$sql .= " GROUP BY s.rowid, s.nom, s.tva_intra, s.tva_assuj";
}
} else {
if ($conf->global->MAIN_MODULE_ACCOUNTING) {
// If vat paid on payments
// TODO a ce jour on se sait pas la compter car le montant tva d'un payment
// n'est pas stocke dans la table des payments.
// Seul le module compta expert peut resoudre ce probleme.
// (Il faut quand un payment a lieu, stocker en plus du montant du paiement le
// detail part tva et part ht).
$sql = 'TODO';
}
if ($conf->global->MAIN_MODULE_COMPTABILITE) {
// Tva sur factures payes (should be on payment)
/* $sql = "SELECT s.rowid as socid, s.nom as nom, s.tva_intra as tva_intra, s.tva_assuj as assuj,";
$sql.= " sum(fd.total_ht) as amount, sum(".$total_tva.") as tva";
$sql.= " FROM ".MAIN_DB_PREFIX.$invoicetable." as f, ".MAIN_DB_PREFIX.$invoicetable." as fd, ".MAIN_DB_PREFIX."societe as s";
$sql.= " WHERE ";
$sql.= " f.fk_statut in (2)"; // Paid (partially or completely)
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $sql.= " AND f.type IN (0,1,2)";
else $sql.= " AND f.type IN (0,1,2,3)";
if ($y && $m)
{
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,$m,false))."'";
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,$m,false))."'";
}
else if ($y)
{
$sql.= " AND f.datef >= '".$db->idate(dol_get_first_day($y,1,false))."'";
$sql.= " AND f.datef <= '".$db->idate(dol_get_last_day($y,12,false))."'";
}
if ($date_start && $date_end) $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
$sql.= " AND s.rowid = f.fk_soc AND f.rowid = fd.".$fk_facture;
$sql.= " GROUP BY s.rowid as socid, s.nom as nom, s.tva_intra as tva_intra, s.tva_assuj as assuj";
*/
$sql = 'TODO';
}
}
if (!$sql) {
return -1;
}
if ($sql == 'TODO') {
return -2;
}
if ($sql != 'TODO') {
dol_syslog("Tax.lib:thirdparty sql=" . $sql);
$resql = $db->query($sql);
if ($resql) {
while ($assoc = $db->fetch_object($resql)) {
$list[] = $assoc;
}
$db->free($resql);
return $list;
} else {
dol_print_error($db);
return -3;
}
}
}
示例6: findAll
/**
* Return all batch detail records for given product and warehouse
*
* @param DoliDB $db database object
* @param int $fk_product_stock id product_stock for objet
* @param int $with_qty doesn't return line with 0 quantity
* @return int <0 if KO, >0 if OK
*/
public static function findAll($db, $fk_product_stock, $with_qty = 0)
{
global $langs;
$ret = array();
$sql = "SELECT";
$sql .= " t.rowid,";
$sql .= " t.tms,";
$sql .= " t.fk_product_stock,";
$sql .= " t.sellby,";
$sql .= " t.eatby,";
$sql .= " t.batch,";
$sql .= " t.qty,";
$sql .= " t.import_key";
$sql .= " FROM " . MAIN_DB_PREFIX . "product_batch as t";
$sql .= " WHERE fk_product_stock=" . $fk_product_stock;
if ($with_qty) {
$sql .= " AND qty<>0";
}
dol_syslog("productbatch::findAll", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
$obj = $db->fetch_object($resql);
$tmp = new productbatch($db);
$tmp->id = $obj->rowid;
$tmp->tms = $db->jdate($obj->tms);
$tmp->fk_product_stock = $obj->fk_product_stock;
$tmp->sellby = $db->jdate($obj->sellby);
$tmp->eatby = $db->jdate($obj->eatby);
$tmp->batch = $obj->batch;
$tmp->qty = $obj->qty;
$tmp->import_key = $obj->import_key;
array_push($ret, $tmp);
$i++;
}
$db->free($resql);
return $ret;
} else {
$error = "Error " . $db->lasterror();
return -1;
}
}
示例7: getListOfModels
/**
* Return list of activated modules usable for document generation
*
* @param DoliDB $db Database handler
* @param string $type Type of models (company, invoice, ...)
* @param int $maxfilenamelength Max length of value to show
* @return mixed 0 if no module is activated, or array(key=>label). For modules that need directory scan, key is completed with ":filename".
*/
function getListOfModels($db, $type, $maxfilenamelength = 0)
{
global $conf, $langs;
$liste = array();
$found = 0;
$dirtoscan = '';
$sql = "SELECT nom as id, nom as lib, libelle as label, description as description";
$sql .= " FROM " . MAIN_DB_PREFIX . "document_model";
$sql .= " WHERE type = '" . $type . "'";
$sql .= " AND entity in (0," . $conf->entity . ")";
//print $sql;
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
$found = 1;
$obj = $db->fetch_object($resql);
// If this generation module needs to scan a directory, then description field is filled
// with the constant that contains list of directories to scan (COMPANY_ADDON_PDF_ODT_PATH, ...).
if (!empty($obj->description)) {
include_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
$const = $obj->description;
$dirtoscan .= ($dirtoscan ? ',' : '') . preg_replace('/[\\r\\n]+/', ',', trim($conf->global->{$const}));
$listoffiles = array();
// Now we add models found in directories scanned
$listofdir = explode(',', $dirtoscan);
foreach ($listofdir as $key => $tmpdir) {
$tmpdir = trim($tmpdir);
if ($conf->multicompany->enabled && $conf->entity > 1) {
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT . "/" . $conf->entity, $tmpdir);
} else {
$tmpdir = preg_replace('/DOL_DATA_ROOT/', DOL_DATA_ROOT, $tmpdir);
}
if (!$tmpdir) {
unset($listofdir[$key]);
continue;
}
if (is_dir($tmpdir)) {
$tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\\.odt');
if (count($tmpfiles)) {
$listoffiles = array_merge($listoffiles, $tmpfiles);
}
}
}
if (count($listoffiles)) {
foreach ($listoffiles as $record) {
$max = $maxfilenamelength ? $maxfilenamelength : 28;
$liste[$obj->id . ':' . $record['fullname']] = dol_trunc($record['name'], $max, 'middle');
}
} else {
$liste[0] = $obj->label . ': ' . $langs->trans("None");
}
} else {
$liste[$obj->id] = $obj->label ? $obj->label : $obj->lib;
}
$i++;
}
} else {
dol_print_error($db);
return -1;
}
if ($found) {
return $liste;
} else {
return 0;
}
}
示例8: setValues
/**
* Load setup values into conf object (read llx_const)
* Note that this->db->xxx, this->file->xxx and this->multicompany have been already loaded when setValues is called.
*
* @param DoliDB $db Database handler
* @return int < 0 if KO, >= 0 if OK
*/
function setValues($db)
{
global $conf;
dol_syslog(get_class($this) . "::setValues");
/*
* Definition de toutes les constantes globales d'environnement
* - En constante php (TODO a virer)
* - En $this->global->key=value
*/
$sql = "SELECT " . $db->decrypt('name') . " as name,";
$sql .= " " . $db->decrypt('value') . " as value, entity";
$sql .= " FROM " . MAIN_DB_PREFIX . "const";
if (!empty($this->multicompany->transverse_mode)) {
$sql .= " WHERE entity IN (0,1," . $this->entity . ")";
} else {
$sql .= " WHERE entity IN (0," . $this->entity . ")";
}
$sql .= " ORDER BY entity";
// This is to have entity 0 first, then entity 1 that overwrite.
$resql = $db->query($sql);
if ($resql) {
$i = 0;
$numr = $db->num_rows($resql);
while ($i < $numr) {
$objp = $db->fetch_object($resql);
$key = $objp->name;
$value = $objp->value;
if ($key) {
if (!defined("{$key}")) {
define("{$key}", $value);
}
// In some cases, the constant might be already forced (Example: SYSLOG_HANDLERS during install)
$this->global->{$key} = $value;
if ($value && preg_match('/^MAIN_MODULE_/', $key)) {
// If this is constant for a new tab page activated by a module. It initializes modules_parts['tabs'].
if (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_TABS_/i', $key)) {
$partname = 'tabs';
$params = explode(':', $value, 2);
if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) {
$this->modules_parts[$partname] = array();
}
$this->modules_parts[$partname][$params[0]][] = $value;
// $value may be a string or an array
} elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)_([A-Z]+)$/i', $key, $reg)) {
$modulename = strtolower($reg[1]);
$partname = strtolower($reg[2]);
if (!isset($this->modules_parts[$partname]) || !is_array($this->modules_parts[$partname])) {
$this->modules_parts[$partname] = array();
}
$arrValue = json_decode($value, true);
if (is_array($arrValue) && !empty($arrValue)) {
$value = $arrValue;
} else {
if (in_array($partname, array('login', 'menus', 'substitutions', 'triggers', 'tpl'))) {
$value = '/' . $modulename . '/core/' . $partname . '/';
} else {
if (in_array($partname, array('models', 'theme'))) {
$value = '/' . $modulename . '/';
} else {
if (in_array($partname, array('sms'))) {
$value = $modulename;
} else {
if ($value == 1) {
$value = '/' . $modulename . '/core/modules/' . $partname . '/';
}
}
}
}
}
// ex: partname = societe
$this->modules_parts[$partname] = array_merge($this->modules_parts[$partname], array($modulename => $value));
// $value may be a string or an array
} elseif (preg_match('/^MAIN_MODULE_([0-9A-Z_]+)$/i', $key, $reg)) {
$modulename = strtolower($reg[1]);
if ($modulename == 'propale') {
$modulename = 'propal';
}
if (!isset($this->{$modulename}) || !is_object($this->{$modulename})) {
$this->{$modulename} = new stdClass();
}
$this->{$modulename}->enabled = true;
$this->modules[] = $modulename;
// Add this module in list of enabled modules
}
}
}
$i++;
}
$db->free($resql);
}
//var_dump($this->modules);
//var_dump($this->modules_parts['theme']);
// If you can't set timezone of your PHP, set this constant. Better is to set it to UTC.
//.........这里部分代码省略.........
示例9: fetchAll
/**
* Retrieve all batch number details link to a shipment line
*
* @param DoliDB $db Database object
* @param int $id_line_expdet id of shipment line
* @return variant -1 if KO, array of ExpeditionLineBatch if OK
*/
static function fetchAll($db, $id_line_expdet)
{
$sql = "SELECT rowid,";
$sql .= "fk_expeditiondet";
$sql .= ", sellby";
$sql .= ", eatby";
$sql .= ", batch";
$sql .= ", qty";
$sql .= ", fk_origin_stock";
$sql .= " FROM " . MAIN_DB_PREFIX . self::$_table_element;
$sql .= " WHERE fk_expeditiondet=" . (int) $id_line_expdet;
dol_syslog(__METHOD__ . "", LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num) {
$tmp = new self($db);
$obj = $db->fetch_object($resql);
$tmp->sellby = $db->jdate($obj->sellby);
$tmp->eatby = $db->jdate($obj->eatby);
$tmp->batch = $obj->batch;
$tmp->id = $obj->rowid;
$tmp->fk_origin_stock = $obj->fk_origin_stock;
$tmp->fk_expeditiondet = $obj->fk_expeditiondet;
$tmp->dluo_qty = $obj->qty;
$ret[] = $tmp;
$i++;
}
$db->free($resql);
return $ret;
} else {
return -1;
}
}
示例10: getEMailTemplate
/**
* Return template of email
* Search into table c_email_templates
*
* @param DoliDB $db Database handler
* @param string $type_template Get message for key module
* @param string $user Use template public or limited to this user
* @param Translate $outputlangs Output lang object
* @param int $id Id template to find
* @return array array('topic'=>,'content'=>,..)
*/
private function getEMailTemplate($db, $type_template, $user, $outputlangs, $id = 0)
{
$ret = array();
$sql = "SELECT label, topic, content, lang";
$sql .= " FROM " . MAIN_DB_PREFIX . 'c_email_templates';
$sql .= " WHERE type_template='" . $db->escape($type_template) . "'";
$sql .= " AND entity IN (" . getEntity("c_email_templates") . ")";
$sql .= " AND (fk_user is NULL or fk_user = 0 or fk_user = " . $user->id . ")";
if (is_object($outputlangs)) {
$sql .= " AND (lang = '" . $outputlangs->defaultlang . "' OR lang IS NULL OR lang = '')";
}
if (!empty($id)) {
$sql .= " AND rowid=" . $id;
}
$sql .= $db->order("lang,label", "ASC");
//print $sql;
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
// Get first found
if ($obj) {
$ret['label'] = $obj->label;
$ret['topic'] = $obj->topic;
$ret['content'] = $obj->content;
$ret['lang'] = $obj->lang;
} else {
$defaultmessage = '';
if ($type_template == 'facture_send') {
$defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendInvoice");
} elseif ($type_template == 'facture_relance') {
$defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendInvoiceReminder");
} elseif ($type_template == 'propal_send') {
$defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendProposal");
} elseif ($type_template == 'askpricesupplier_send') {
$defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendAskPriceSupplier");
} elseif ($type_template == 'order_send') {
$defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendOrder");
} elseif ($type_template == 'order_supplier_send') {
$defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierOrder");
} elseif ($type_template == 'invoice_supplier_send') {
$defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendSupplierInvoice");
} elseif ($type_template == 'shipping_send') {
$defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendShipping");
} elseif ($type_template == 'fichinter_send') {
$defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendFichInter");
} elseif ($type_template == 'thirdparty') {
$defaultmessage = $outputlangs->transnoentities("PredefinedMailContentThirdparty");
}
$ret['label'] = 'default';
$ret['topic'] = '';
$ret['content'] = $defaultmessage;
$ret['lang'] = $outputlangs->defaultlang;
}
$db->free($resql);
return $ret;
} else {
dol_print_error($db);
return -1;
}
}
示例11: migrate_event_assignement
/**
* Migrate event assignement to owner
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_event_assignement($db, $langs, $conf)
{
print '<tr><td colspan="4">';
print '<br>';
print '<b>' . $langs->trans('MigrationEvents') . "</b><br>\n";
$error = 0;
dolibarr_install_syslog("upgrade2::migrate_event_assignement");
$db->begin();
$sqlSelect = "SELECT a.id, a.fk_user_action";
$sqlSelect .= " FROM " . MAIN_DB_PREFIX . "actioncomm as a";
$sqlSelect .= " LEFT JOIN " . MAIN_DB_PREFIX . "actioncomm_resources as ar ON ar.fk_actioncomm = a.id AND ar.element_type = 'user' AND ar.fk_element = a.fk_user_action";
$sqlSelect .= " WHERE fk_user_action > 0 AND fk_user_action NOT IN (SELECT fk_element FROM " . MAIN_DB_PREFIX . "actioncomm_resources as ar WHERE ar.fk_actioncomm = a.id AND ar.element_type = 'user')";
$sqlSelect .= " ORDER BY a.id";
//print $sqlSelect;
$resql = $db->query($sqlSelect);
if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
if ($num) {
while ($i < $num) {
$obj = $db->fetch_object($resql);
$sqlUpdate = "INSERT INTO " . MAIN_DB_PREFIX . "actioncomm_resources(fk_actioncomm, element_type, fk_element) ";
$sqlUpdate .= "VALUES(" . $obj->id . ", 'user', " . $obj->fk_user_action . ")";
$result = $db->query($sqlUpdate);
if (!$result) {
$error++;
dol_print_error($db);
}
print ". ";
$i++;
}
} else {
print $langs->trans('AlreadyDone') . "<br>\n";
}
if (!$error) {
$db->commit();
} else {
$db->rollback();
}
} else {
dol_print_error($db);
$db->rollback();
}
print '</td></tr>';
}
示例12: listBoxes
/**
* Return array of boxes qualified for area and user
*
* @param DoliDB $db Database handler
* @param string $mode 'available' or 'activated'
* @param string $zone Name or area (-1 for all, 0 for Homepage, 1 for xxx, ...)
* @param User $user Objet user to filter (used only if $zone >= 0)
* @param array $excludelist Array of box id (box.box_id = boxes_def.rowid) to exclude
* @return array Array of boxes
*/
static function listBoxes($db, $mode, $zone, $user, $excludelist = array())
{
global $conf;
$boxes = array();
$confuserzone = 'MAIN_BOXES_' . $zone;
if ($mode == 'activated') {
$sql = "SELECT b.rowid, b.position, b.box_order, b.fk_user,";
$sql .= " d.rowid as box_id, d.file, d.note, d.tms";
$sql .= " FROM " . MAIN_DB_PREFIX . "boxes as b, " . MAIN_DB_PREFIX . "boxes_def as d";
$sql .= " WHERE b.box_id = d.rowid";
$sql .= " AND d.entity = " . $conf->entity;
if ($zone >= 0) {
$sql .= " AND b.position = " . $zone;
}
if ($user->id && $user->conf->{$confuserzone}) {
$sql .= " AND b.fk_user = " . $user->id;
} else {
$sql .= " AND b.fk_user = 0";
}
$sql .= " ORDER BY b.box_order";
} else {
$sql = "SELECT d.rowid as box_id, d.file, d.note, d.tms";
$sql .= " FROM " . MAIN_DB_PREFIX . "boxes_def as d";
$sql .= " WHERE entity = " . $conf->entity;
}
$resql = $db->query($sql);
if ($resql) {
$num = $db->num_rows($resql);
$j = 0;
while ($j < $num) {
$obj = $db->fetch_object($resql);
if (!in_array($obj->box_id, $excludelist)) {
if (preg_match('/^([^@]+)@([^@]+)$/i', $obj->file, $regs)) {
$boxname = $regs[1];
$module = $regs[2];
$relsourcefile = "/" . $module . "/core/boxes/" . $boxname . ".php";
} else {
$boxname = preg_replace('/.php$/i', '', $obj->file);
$relsourcefile = "/core/boxes/" . $boxname . ".php";
}
dol_include_once($relsourcefile);
if (class_exists($boxname)) {
$box = new $boxname($db, $obj->note);
// box properties
$box->rowid = !empty($obj->rowid) ? $obj->rowid : '';
$box->id = !empty($obj->box_id) ? $obj->box_id : '';
$box->position = !empty($obj->position) ? $obj->position : '';
$box->box_order = !empty($obj->box_order) ? $obj->box_order : '';
$box->fk_user = !empty($obj->fk_user) ? $obj->fk_user : '';
$box->sourcefile = $relsourcefile;
if ($mode == 'activated' && (!$user->id || !$user->conf->{$confuserzone})) {
if (is_numeric($box->box_order)) {
if ($box->box_order % 2 == 1) {
$box->box_order = 'A' . $box->box_order;
} elseif ($box->box_order % 2 == 0) {
$box->box_order = 'B' . $box->box_order;
}
}
}
// box_def properties
$box->box_id = !empty($obj->box_id) ? $obj->box_id : '';
$box->note = !empty($obj->note) ? $obj->note : '';
$enabled = true;
if (isset($box->depends) && count($box->depends) > 0) {
foreach ($box->depends as $module) {
//print $boxname.'-'.$module.'<br>';
if (empty($conf->{$module}->enabled)) {
$enabled = false;
}
}
}
if ($enabled) {
$boxes[] = $box;
}
}
}
$j++;
}
} else {
//dol_print_error($db);
$this->error = $db->error();
dol_syslog(get_class() . "::listBoxes Error " . $this->error, LOG_ERR);
return array();
}
return $boxes;
}
示例13: migrate_actioncomm_element
/**
* Migrate link stored into fk_xxxx into fk_element and elementtype
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_actioncomm_element($db,$langs,$conf)
{
print '<tr><td colspan="4">';
print '<br>';
print '<b>'.$langs->trans('MigrationActioncommElement')."</b><br>\n";
$elements = array(
'propal' => 'propalrowid',
'order' => 'fk_commande',
'invoice' => 'fk_facture',
'contract' => 'fk_contract',
'order_supplier' => 'fk_supplier_order',
'invoice_supplier' => 'fk_supplier_invoice'
);
foreach($elements as $type => $field)
{
$result = $db->DDLDescTable(MAIN_DB_PREFIX."actioncomm",$field);
$obj = $db->fetch_object($result);
if ($obj)
{
dolibarr_install_syslog("upgrade2::migrate_actioncomm_element field=".$field);
$db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm SET ";
$sql.= "fk_element = ".$field.", elementtype = '".$type."'";
$sql.= " WHERE ".$field." IS NOT NULL";
$sql.= " AND fk_element IS NULL";
$sql.= " AND elementtype IS NULL";
$resql = $db->query($sql);
if ($resql)
{
$db->commit();
// DDL commands must not be inside a transaction
// We will drop at next version because a migrate should be runnable several times if it fails.
//$sqlDrop = "ALTER TABLE ".MAIN_DB_PREFIX."actioncomm DROP COLUMN ".$field;
//$db->query($sqlDrop);
//print ". ";
}
else
{
dol_print_error($db);
$db->rollback();
}
}
else
{
print $langs->trans('AlreadyDone')."<br>\n";
}
}
print '</td></tr>';
}
示例14: dol_getIdFromCode
/**
* Return an id or code from a code or id. Store also Code-Id into a cache for next use.
*
* @param DoliDB $db Database handler
* @param string $key Code to get Id
* @param string $tablename Table name without prefix
* @param string $fieldkey Field for code
* @param string $fieldid Field for id
* @return int <0 if KO, Id of code if OK
* @see getLabelFromKey
*/
function dol_getIdFromCode($db, $key, $tablename, $fieldkey = 'code', $fieldid = 'id')
{
global $cache_codes;
// If key empty
if ($key == '') {
return '';
}
// Check in cache
if (isset($cache_codes[$tablename][$key])) {
return $cache_codes[$tablename][$key];
// Found in cache
}
$sql = "SELECT " . $fieldid . " as id";
$sql .= " FROM " . MAIN_DB_PREFIX . $tablename;
$sql .= " WHERE " . $fieldkey . " = '" . $key . "'";
dol_syslog('dol_getIdFromCode', LOG_DEBUG);
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj) {
$cache_codes[$tablename][$key] = $obj->id;
} else {
$cache_codes[$tablename][$key] = '';
}
$db->free($resql);
return $cache_codes[$tablename][$key];
} else {
return -1;
}
}
示例15: migrate_categorie_association
/**
* Migrate categorie association
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_categorie_association($db, $langs, $conf)
{
print '<tr><td colspan="4">';
print '<br>';
print '<b>' . $langs->trans('MigrationCategorieAssociation') . "</b><br>\n";
$error = 0;
if ($db->DDLInfoTable(MAIN_DB_PREFIX . "categorie_association")) {
dolibarr_install_syslog("upgrade2::migrate_categorie_association");
$db->begin();
$sqlSelect = "SELECT fk_categorie_mere, fk_categorie_fille";
$sqlSelect .= " FROM " . MAIN_DB_PREFIX . "categorie_association";
$resql = $db->query($sqlSelect);
if ($resql) {
$i = 0;
$num = $db->num_rows($resql);
if ($num) {
while ($i < $num) {
$obj = $db->fetch_object($resql);
$sqlUpdate = "UPDATE " . MAIN_DB_PREFIX . "categorie SET ";
$sqlUpdate .= "fk_parent = " . $obj->fk_categorie_mere;
$sqlUpdate .= " WHERE rowid = " . $obj->fk_categorie_fille;
$result = $db->query($sqlUpdate);
if (!$result) {
$error++;
dol_print_error($db);
}
print ". ";
$i++;
}
} else {
print $langs->trans('AlreadyDone') . "<br>\n";
}
if (!$error) {
// TODO DROP table in the next release
/*
$sqlDrop = "DROP TABLE ".MAIN_DB_PREFIX."categorie_association";
if ($db->query($sqlDrop))
{
$db->commit();
}
else
{
$db->rollback();
}
*/
$db->commit();
} else {
$db->rollback();
}
} else {
dol_print_error($db);
$db->rollback();
}
} else {
print $langs->trans('AlreadyDone') . "<br>\n";
}
print '</td></tr>';
}