本文整理汇总了PHP中DoliDB::num_rows方法的典型用法代码示例。如果您正苦于以下问题:PHP DoliDB::num_rows方法的具体用法?PHP DoliDB::num_rows怎么用?PHP DoliDB::num_rows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoliDB
的用法示例。
在下文中一共展示了DoliDB::num_rows方法的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: 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.
//.........这里部分代码省略.........
示例3: 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;
}
}
示例4: print_projecttasks_array
/**
* Return HTML table with list of projects and number of opened tasks
*
* @param DoliDB $db Database handler
* @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
* @return void
*/
function print_projecttasks_array($db, $socid, $projectsListId, $mytasks = 0)
{
global $langs, $conf, $user, $bc;
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
$projectstatic = new Project($db);
$sortfield = '';
$sortorder = '';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("Project"), "index.php", "", "", "", "", $sortfield, $sortorder);
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, COUNT(t.rowid) as nb";
$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;
}
$sql .= " GROUP BY p.rowid, p.ref, p.title, p.fk_user_creat, p.public, p.fk_statut";
$sql .= " ORDER BY p.title, p.ref";
$var = true;
$resql = $db->query($sql);
if ($resql) {
$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>';
print '<td align="right">' . $objp->nb . '</td>';
$projectstatic->statut = $objp->fk_statut;
print '<td align="right">' . $projectstatic->getLibStatut(3) . '</td>';
print "</tr>\n";
}
$i++;
}
$db->free($resql);
} else {
dol_print_error($db);
}
print "</table>";
}
示例5: 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);
//.........这里部分代码省略.........
示例6:
/**
* Return if a code is used (by other element)
*
* @param DoliDB $db Handler acces base
* @param string $code Code a verifier
* @param Product $product Objet product
* @return int 0 if available, <0 if KO
*/
function verif_dispo($db, $code, $product)
{
$sql = "SELECT barcode FROM " . MAIN_DB_PREFIX . "product";
$sql .= " WHERE barcode = '" . $code . "'";
if ($product->id > 0) {
$sql .= " AND rowid <> " . $product->id;
}
$resql = $db->query($sql);
if ($resql) {
if ($db->num_rows($resql) == 0) {
return 0;
} else {
return -1;
}
} else {
return -2;
}
}
示例7: 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;
}
}
示例8: 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;
}
}
示例9: show_subsidiaries
/**
* Show html area for list of subsidiaries
*
* @param Conf $conf Object conf
* @param Translate $langs Object langs
* @param DoliDB $db Database handler
* @param Societe $object Third party object
* @return void
*/
function show_subsidiaries($conf, $langs, $db, $object)
{
global $user;
global $bc;
$i = -1;
$sql = "SELECT s.rowid, s.nom as name, s.address, s.zip, s.town, s.code_client, s.canvas";
$sql .= " FROM " . MAIN_DB_PREFIX . "societe as s";
$sql .= " WHERE s.parent = " . $object->id;
$sql .= " AND s.entity IN (" . getEntity('societe', 1) . ")";
$sql .= " ORDER BY s.nom";
$result = $db->query($sql);
$num = $db->num_rows($result);
if ($num) {
$socstatic = new Societe($db);
print_titre($langs->trans("Subsidiaries"));
print "\n" . '<table class="noborder" width="100%">' . "\n";
print '<tr class="liste_titre"><td>' . $langs->trans("Company") . '</td>';
print '<td>' . $langs->trans("Address") . '</td><td>' . $langs->trans("Zip") . '</td>';
print '<td>' . $langs->trans("Town") . '</td><td>' . $langs->trans("CustomerCode") . '</td>';
print "<td> </td>";
print "</tr>";
$i = 0;
$var = true;
while ($i < $num) {
$obj = $db->fetch_object($result);
$var = !$var;
print "<tr " . $bc[$var] . ">";
print '<td>';
$socstatic->id = $obj->rowid;
$socstatic->name = $obj->name;
$socstatic->canvas = $obj->canvas;
print $socstatic->getNomUrl(1);
print '</td>';
print '<td>' . $obj->address . '</td>';
print '<td>' . $obj->zip . '</td>';
print '<td>' . $obj->town . '</td>';
print '<td>' . $obj->code_client . '</td>';
print '<td align="center">';
print '<a href="' . DOL_URL_ROOT . '/societe/soc.php?socid=' . $obj->rowid . '&action=edit">';
print img_edit();
print '</a></td>';
print "</tr>\n";
$i++;
}
print "\n</table>\n";
}
print "<br>\n";
return $i;
}
示例10:
/**
* Renvoi si un code est pris ou non (par autre tiers)
*
* @param DoliDB $db Handler acces base
* @param string $code Code a verifier
* @param Societe $soc Objet societe
* @return int 0 if available, <0 if KO
*/
function verif_dispo($db, $code, $soc)
{
$sql = "SELECT code_client FROM " . MAIN_DB_PREFIX . "societe";
$sql .= " WHERE code_client = '" . $code . "'";
if ($soc->id > 0) {
$sql .= " AND rowid <> " . $soc->id;
}
$resql = $db->query($sql);
if ($resql) {
if ($db->num_rows($resql) == 0) {
return 0;
} else {
return -1;
}
} else {
return -2;
}
}
示例11: verif
/**
* Return if a code is available
*
* @param DoliDB $db Database handler
* @param string $code Code of third party
* @param Societe $societe Object third party
* @param string $type 'supplier' or 'customer'
* @return int 0 if OK but not available, >0 if OK and available, <0 if KO
*/
function verif($db, $code, $societe, $type)
{
$sql = "SELECT ";
if ($type == 'customer') {
$sql .= "code_compta";
} else {
if ($type == 'supplier') {
$sql .= "code_compta_fournisseur";
}
}
$sql .= " FROM " . MAIN_DB_PREFIX . "societe";
$sql .= " WHERE ";
if ($type == 'customer') {
$sql .= "code_compta";
} else {
if ($type == 'supplier') {
$sql .= "code_compta_fournisseur";
}
}
$sql .= " = '" . $this->db->escape($code) . "'";
if (!empty($societe->id)) {
$sql .= " AND rowid <> " . $societe->id;
}
$resql = $db->query($sql);
if ($resql) {
if ($db->num_rows($resql) == 0) {
dol_syslog("mod_codecompta_aquarium::verif code '" . $code . "' available");
return 1;
// Dispo
} else {
dol_syslog("mod_codecompta_aquarium::verif code '" . $code . "' not available");
return 0;
// Non dispo
}
} else {
$this->error = $db->error() . " sql=" . $sql;
dol_syslog("mod_codecompta_aquarium::verif error" . $this->error, LOG_ERR);
return -1;
// Erreur
}
}
示例12: 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>';
}
示例13: 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;
}
示例14: migrate_mode_reglement
/**
* Migrate link stored into fk_mode_reglement
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_mode_reglement($db,$langs,$conf)
{
print '<tr><td colspan="4">';
print '<br>';
print '<b>'.$langs->trans('MigrationPaymentMode')."</b><br>\n";
$elements = array(
'old_id' => array(5,8,9,10,11),
'new_id' => array(50,51,52,53,54),
'code' => array('VAD','TRA','LCR','FAC','PRO'),
'tables' => array('commande_fournisseur','commande','facture_rec','facture','propal')
);
$count=0;
foreach($elements['old_id'] as $key => $old_id)
{
$error=0;
dolibarr_install_syslog("upgrade2::migrate_mode_reglement code=".$elements['code'][$key]);
$sqlSelect = "SELECT id";
$sqlSelect.= " FROM ".MAIN_DB_PREFIX."c_paiement";
$sqlSelect.= " WHERE id = ".$old_id;
$sqlSelect.= " AND code = '".$elements['code'][$key]."'";
$resql = $db->query($sqlSelect);
if ($resql)
{
$num = $db->num_rows($resql);
if ($num)
{
$count++;
$db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."c_paiement SET ";
$sql.= "id = ".$elements['new_id'][$key];
$sql.= " WHERE id = ".$old_id;
$sql.= " AND code = '".$elements['code'][$key]."'";
$resql = $db->query($sql);
if ($resql)
{
foreach($elements['tables'] as $table)
{
$sql = "UPDATE ".MAIN_DB_PREFIX.$table." SET ";
$sql.= "fk_mode_reglement = ".$elements['new_id'][$key];
$sql.= " WHERE fk_mode_reglement = ".$old_id;
$resql = $db->query($sql);
if (! $resql)
{
dol_print_error($db);
$error++;
}
print ". ";
}
if (! $error)
{
$db->commit();
}
else
{
dol_print_error($db);
$db->rollback();
}
}
else
{
dol_print_error($db);
$db->rollback();
}
}
}
}
if ($count == 0) print $langs->trans('AlreadyDone')."<br>\n";
print '</td></tr>';
}
示例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>';
}