当前位置: 首页>>代码示例>>PHP>>正文


PHP DoliDB::query方法代码示例

本文整理汇总了PHP中DoliDB::query方法的典型用法代码示例。如果您正苦于以下问题:PHP DoliDB::query方法的具体用法?PHP DoliDB::query怎么用?PHP DoliDB::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DoliDB的用法示例。


在下文中一共展示了DoliDB::query方法的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>&nbsp;</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 >&nbsp;</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>&nbsp;</td></tr>";
        print "</table>";
        $db->free($result);
    } else {
        dol_print_error($db);
    }
}
开发者ID:TAASA,项目名称:Dolibarr-ERP-3.8.1,代码行数:40,代码来源:index.php

示例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;
     }
 }
开发者ID:Samara94,项目名称:dolibarr,代码行数:37,代码来源:actions_adherentcard_common.class.php

示例3: 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;
 }
开发者ID:nrjacker4,项目名称:crm-php,代码行数:96,代码来源:infobox.class.php

示例4:

 /**
  *		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;
     }
 }
开发者ID:ADDAdev,项目名称:Dolibarr,代码行数:26,代码来源:mod_barcode_product_standard.php

示例5: print_left_auguria_menu

/**
 * Core function to output left menu auguria
 *
 * @param	DoliDB		$db                 Database handler
 * @param 	array		$menu_array_before  Table of menu entries to show before entries of menu handler
 * @param   array		$menu_array_after   Table of menu entries to show after entries of menu handler
 * @param  	array		$tabMenu       		If array with menu entries already loaded, we put this array here (in most cases, it's empty)
 * @param	Menu		$menu				Object Menu to return back list of menu entries
 * @param	int			$noout				Disable output (Initialise &$menu only).
 * @param	string		$forcemainmenu		'x'=Force mainmenu to mainmenu='x'
 * @param	string		$forceleftmenu		'all'=Force leftmenu to '' (= all)
 * @param	array		$moredata			An array with more data to output
 * @return	int								Nb of entries
 */
function print_left_auguria_menu($db, $menu_array_before, $menu_array_after, &$tabMenu, &$menu, $noout = 0, $forcemainmenu = '', $forceleftmenu = '', $moredata = null)
{
    global $user, $conf, $langs, $dolibarr_main_db_name, $mysoc;
    $newmenu = $menu;
    $mainmenu = $forcemainmenu ? $forcemainmenu : $_SESSION["mainmenu"];
    $leftmenu = $forceleftmenu ? '' : (empty($_SESSION["leftmenu"]) ? 'none' : $_SESSION["leftmenu"]);
    // Show logo company
    if (empty($noout) && !empty($conf->global->MAIN_SHOW_LOGO) && empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
        $mysoc->logo_mini = $conf->global->MAIN_INFO_SOCIETE_LOGO_MINI;
        if (!empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output . '/logos/thumbs/' . $mysoc->logo_mini)) {
            $urllogo = DOL_URL_ROOT . '/viewimage.php?cache=1&amp;modulepart=companylogo&amp;file=' . urlencode('thumbs/' . $mysoc->logo_mini);
        } else {
            $urllogo = DOL_URL_ROOT . '/theme/dolibarr_logo.png';
        }
        $title = $langs->trans("GoIntoSetupToChangeLogo");
        print "\n" . '<!-- Show logo on menu -->' . "\n";
        print '<div class="blockvmenuimpair blockvmenulogo">' . "\n";
        print '<div class="menu_titre" id="menu_titre_logo"></div>';
        print '<div class="menu_top" id="menu_top_logo"></div>';
        print '<div class="menu_contenu" id="menu_contenu_logo">';
        print '<div class="center"><img title="' . dol_escape_htmltag($title) . '" alt="" src="' . $urllogo . '" style="max-width: 80%"></div>' . "\n";
        print '</div>';
        print '<div class="menu_end" id="menu_end_logo"></div>';
        print '</div>' . "\n";
    }
    if (is_array($moredata) && !empty($moredata['searchform'])) {
        print "\n";
        print "<!-- Begin SearchForm -->\n";
        print '<div id="blockvmenusearch" class="blockvmenusearch">' . "\n";
        print $moredata['searchform'];
        print '</div>' . "\n";
        print "<!-- End SearchForm -->\n";
    }
    // We update newmenu with entries found into database
    $menuArbo = new Menubase($db, 'auguria');
    $newmenu = $menuArbo->menuLeftCharger($newmenu, $mainmenu, $leftmenu, $user->societe_id ? 1 : 0, 'auguria', $tabMenu);
    // We update newmenu for special dynamic menus
    if ($conf->banque->enabled && $user->rights->banque->lire && $mainmenu == 'bank') {
        $sql = "SELECT rowid, label, courant, rappro, courant";
        $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) {
                $newmenu->add('/compta/bank/index.php', $langs->trans("BankAccounts"), 0, $user->rights->banque->lire);
            }
            while ($i < $numr) {
                $objp = $db->fetch_object($resql);
                $newmenu->add('/compta/bank/card.php?id=' . $objp->rowid, $objp->label, 1, $user->rights->banque->lire);
                if ($objp->rappro && $objp->courant != 2 && empty($objp->clos)) {
                    $newmenu->add('/compta/bank/rappro.php?account=' . $objp->rowid, $langs->trans("Conciliate"), 2, $user->rights->banque->consolidate);
                }
                $i++;
            }
        } else {
            dol_print_error($db);
        }
        $db->free($resql);
    }
    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);
//.........这里部分代码省略.........
开发者ID:Samara94,项目名称:dolibarr,代码行数:101,代码来源:auguria.lib.php

示例6: tva_paye

/**
 * Gets VAT to pay for the given month of the given year
 * The function gets the VAT in split results, as the VAT declaration asks
 * to report the amounts for different VAT rates as different lines
 *
 * @param	DoliDB	$db			Database handler object
 * @param	int		$y			Year
 * @param	int		$q			Year quarter (1-4)
 * @return	array
 */
function tva_paye($db, $y, $q)
{
    global $conf;
    if ($conf->global->ACCOUNTING_MODE == "CREANCES-DETTES") {
        // Si on paye la tva sur les factures dues (non brouillon)
        $sql = "SELECT d.fk_facture_fourn as facid, f.ref_supplier as facnum, d.tva_tx as rate, d.total_ht as totalht, d.tva as amount";
        $sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn as f";
        $sql .= ", " . MAIN_DB_PREFIX . "facture_fourn_det as d";
        $sql .= ", " . MAIN_DB_PREFIX . "societe as s";
        $sql .= " WHERE f.fk_soc = s.rowid";
        $sql .= " AND f.entity = " . $conf->entity;
        $sql .= " AND f.fk_statut = 1 ";
        $sql .= " AND f.rowid = d.fk_facture_fourn ";
        $sql .= " AND date_format(f.datef,'%Y') = '" . $y . "'";
        $sql .= " AND (round(date_format(f.datef,'%m')) > " . ($q - 1) * 3;
        $sql .= " AND round(date_format(f.datef,'%m')) <= " . $q * 3 . ")";
        $sql .= " ORDER BY rate, facid ";
    } else {
        // Si on paye la tva sur les payments
    }
    $resql = $db->query($sql);
    if ($resql) {
        $list = array();
        $rate = -1;
        while ($assoc = $db->fetch_array($resql)) {
            if ($assoc['rate'] != $rate) {
                //new rate
                $list[$assoc['rate']]['totalht'] = $assoc['totalht'];
                $list[$assoc['rate']]['vat'] = $assoc['amount'];
                $list[$assoc['rate']]['facid'][] = $assoc['facid'];
                $list[$assoc['rate']]['facnum'][] = $assoc['facnum'];
            } else {
                $list[$assoc['rate']]['totalht'] += $assoc['totalht'];
                $list[$assoc['rate']]['vat'] += $assoc['amount'];
                if (!in_array($assoc['facid'], $list[$assoc['rate']]['facid'])) {
                    $list[$assoc['rate']]['facid'][] = $assoc['facid'];
                    $list[$assoc['rate']]['facnum'][] = $assoc['facnum'];
                }
            }
            $rate = $assoc['rate'];
        }
        return $list;
    } else {
        dol_print_error($db);
    }
}
开发者ID:TAASA,项目名称:Dolibarr-ERP-3.8.1,代码行数:56,代码来源:quadri.php

示例7: 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|null   $user	  		Object user to filter
  *  @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 = null, $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 b.entity IN (0," . (!empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode) ? "1," : "") . $conf->entity . ")";
         if ($zone >= 0) {
             $sql .= " AND b.position = " . $zone;
         }
         if (is_object($user)) {
             $sql .= " AND b.fk_user IN (0," . $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 d.entity IN (0," . (!empty($conf->multicompany->enabled) && !empty($conf->multicompany->transverse_mode) ? "1," : "") . $conf->entity . ")";
     }
     dol_syslog(get_class() . "::listBoxes get default box list for mode=" . $mode . " userid=" . (is_object($user) ? $user->id : '') . "", LOG_DEBUG);
     $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 = preg_replace('/\\.php$/i', '', $regs[1]);
                     $module = $regs[2];
                     $relsourcefile = "/" . $module . "/core/boxes/" . $boxname . ".php";
                 } else {
                     $boxname = preg_replace('/\\.php$/i', '', $obj->file);
                     $relsourcefile = "/core/boxes/" . $boxname . ".php";
                 }
                 //print $obj->box_id.'-'.$boxname.'-'.$relsourcefile.'<br>';
                 // TODO PERF Do not make "dol_include_once" here, nor "new" later. This means, we must store a 'depends' field to store modules list, then
                 // the "enabled" condition for modules forbidden for external users and the depends condition can be done.
                 // Goal is to avoid making a "new" done for each boxes returned by select.
                 dol_include_once($relsourcefile);
                 if (class_exists($boxname)) {
                     $box = new $boxname($db, $obj->note);
                     // Constructor may set properties like box->enabled. obj->note is note into box def, not user params.
                     //$box=new stdClass();
                     // box properties
                     $box->rowid = empty($obj->rowid) ? '' : $obj->rowid;
                     $box->id = empty($obj->box_id) ? '' : $obj->box_id;
                     $box->position = $obj->position == '' ? '' : $obj->position;
                     // '0' must staty '0'
                     $box->box_order = empty($obj->box_order) ? '' : $obj->box_order;
                     $box->fk_user = empty($obj->fk_user) ? 0 : $obj->fk_user;
                     $box->sourcefile = $relsourcefile;
                     $box->class = $boxname;
                     if ($mode == 'activated' && !is_object($user)) {
                         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;
                     // Filter on box->enabled (used for example by box_comptes)
                     // Filter also on box->depends. Example: array("product|service") or array("contrat", "service")
                     $enabled = $box->enabled;
                     if (isset($box->depends) && count($box->depends) > 0) {
                         foreach ($box->depends as $moduleelem) {
                             $arrayelem = explode('|', $moduleelem);
                             $tmpenabled = 0;
                             // $tmpenabled is used for the '|' test (OR)
                             foreach ($arrayelem as $module) {
                                 $tmpmodule = preg_replace('/@[^@]+/', '', $module);
                                 if (!empty($conf->{$tmpmodule}->enabled)) {
                                     $tmpenabled = 1;
                                 }
                                 //print $boxname.'-'.$module.'-module enabled='.(empty($conf->$tmpmodule->enabled)?0:1).'<br>';
                             }
                             if (empty($tmpenabled)) {
                                 $enabled = 0;
                                 break;
                             }
//.........这里部分代码省略.........
开发者ID:Samara94,项目名称:dolibarr,代码行数:101,代码来源:infobox.class.php

示例8: getLabelFromKey

 /**
  *      Return a label for a key.
  *      Search into translation array, then into cache, then if still not found, search into database.
  *      Store key-label found into cache variable $this->cache_labels to save SQL requests to get labels.
  *
  * 		@param	DoliDB	$db				Database handler
  * 		@param	string	$key			Translation key to get label (key in language file)
  * 		@param	string	$tablename		Table name without prefix
  * 		@param	string	$fieldkey		Field for key
  * 		@param	string	$fieldlabel		Field for label
  *      @param	string	$keyforselect	Use another value than the translation key for the where into select
  *      @return string					Label in UTF8 (but without entities)
  *      @see dol_getIdFromCode
  */
 function getLabelFromKey($db, $key, $tablename, $fieldkey, $fieldlabel, $keyforselect = '')
 {
     // If key empty
     if ($key == '') {
         return '';
     }
     //print 'param: '.$key.'-'.$keydatabase.'-'.$this->trans($key); exit;
     // Check if a translation is available (this can call getTradFromKey)
     if ($this->transnoentitiesnoconv($key) != $key) {
         return $this->transnoentitiesnoconv($key);
         // Found in language array
     }
     // Check in cache
     if (isset($this->cache_labels[$tablename][$key])) {
         return $this->cache_labels[$tablename][$key];
         // Found in cache
     }
     $sql = "SELECT " . $fieldlabel . " as label";
     $sql .= " FROM " . MAIN_DB_PREFIX . $tablename;
     $sql .= " WHERE " . $fieldkey . " = '" . ($keyforselect ? $keyforselect : $key) . "'";
     dol_syslog(get_class($this) . '::getLabelFromKey', LOG_DEBUG);
     $resql = $db->query($sql);
     if ($resql) {
         $obj = $db->fetch_object($resql);
         if ($obj) {
             $this->cache_labels[$tablename][$key] = $obj->label;
         } else {
             $this->cache_labels[$tablename][$key] = $key;
         }
         $db->free($resql);
         return $this->cache_labels[$tablename][$key];
     } else {
         $this->error = $db->lasterror();
         return -1;
     }
 }
开发者ID:TAASA,项目名称:Dolibarr-ERP-3.8.1,代码行数:50,代码来源:translate.class.php

示例9: cleanCorruptedTree

/**
 * Clean corrupted tree (orphelins linked to a not existing parent), record linked to themself and child-parent loop
 *
 * @param	DoliDB	$db					Database handler
 * @param	string	$tabletocleantree	Table to clean
 * @param	string	$fieldfkparent		Field name that contains id of parent
 * @return	int							Nb of records fixed/deleted
 */
function cleanCorruptedTree($db, $tabletocleantree, $fieldfkparent)
{
    $totalnb = 0;
    $listofid = array();
    $listofparentid = array();
    // Get list of all id in array listofid and all parents in array listofparentid
    $sql = 'SELECT rowid, ' . $fieldfkparent . ' as parent_id FROM ' . MAIN_DB_PREFIX . $tabletocleantree;
    $resql = $db->query($sql);
    if ($resql) {
        $num = $db->num_rows($resql);
        $i = 0;
        while ($i < $num) {
            $obj = $db->fetch_object($resql);
            $listofid[] = $obj->rowid;
            if ($obj->parent_id > 0) {
                $listofparentid[$obj->rowid] = $obj->parent_id;
            }
            $i++;
        }
    } else {
        dol_print_error($db);
    }
    if (count($listofid)) {
        print 'Code requested to clean tree (may be to solve data corruption), so we check/clean orphelins and loops.' . "<br>\n";
        // Check loops on each other
        $sql = "UPDATE " . MAIN_DB_PREFIX . $tabletocleantree . " SET " . $fieldfkparent . " = 0 WHERE " . $fieldfkparent . " = rowid";
        // So we update only records linked to themself
        $resql = $db->query($sql);
        if ($resql) {
            $nb = $db->affected_rows($sql);
            if ($nb > 0) {
                print '<br>Some record that were parent of themself were cleaned.';
            }
            $totalnb += $nb;
        }
        //else dol_print_error($db);
        // Check other loops
        $listofidtoclean = array();
        foreach ($listofparentid as $id => $pid) {
            // Check depth
            //print 'Analyse record id='.$id.' with parent '.$pid.'<br>';
            $cursor = $id;
            $arrayidparsed = array();
            // We start from child $id
            while ($cursor > 0) {
                $arrayidparsed[$cursor] = 1;
                if ($arrayidparsed[$listofparentid[$cursor]]) {
                    print 'Found a loop between id ' . $id . ' - ' . $cursor . '<br>';
                    unset($arrayidparsed);
                    $listofidtoclean[$cursor] = $id;
                    break;
                }
                $cursor = $listofparentid[$cursor];
            }
            if (count($listofidtoclean)) {
                break;
            }
        }
        $sql = "UPDATE " . MAIN_DB_PREFIX . $tabletocleantree;
        $sql .= " SET " . $fieldfkparent . " = 0";
        $sql .= " WHERE rowid IN (" . join(',', $listofidtoclean) . ")";
        // So we update only records detected wrong
        $resql = $db->query($sql);
        if ($resql) {
            $nb = $db->affected_rows($sql);
            if ($nb > 0) {
                // Removed orphelins records
                print '<br>Some records were detected to have parent that is a child, we set them as root record for id: ';
                print join(',', $listofidtoclean);
            }
            $totalnb += $nb;
        }
        //else dol_print_error($db);
        // Check and clean orphelins
        $sql = "UPDATE " . MAIN_DB_PREFIX . $tabletocleantree;
        $sql .= " SET " . $fieldfkparent . " = 0";
        $sql .= " WHERE " . $fieldfkparent . " NOT IN (" . join(',', $listofid) . ")";
        // So we update only records linked to a non existing parent
        $resql = $db->query($sql);
        if ($resql) {
            $nb = $db->affected_rows($sql);
            if ($nb > 0) {
                // Removed orphelins records
                print '<br>Some orphelins were found and modified to be parent so records are visible again for id: ';
                print join(',', $listofid);
            }
            $totalnb += $nb;
        }
        //else dol_print_error($db);
        print '<br>We fixed ' . $totalnb . ' record(s). Some records may still be corrupted. New check may be required.';
        return $totalnb;
    }
//.........这里部分代码省略.........
开发者ID:Albertopf,项目名称:prueba,代码行数:101,代码来源:functions2.lib.php

示例10: 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>&nbsp;</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 . '&amp;action=edit">';
            print img_edit();
            print '</a></td>';
            print "</tr>\n";
            $i++;
        }
        print "\n</table>\n";
    }
    print "<br>\n";
    return $i;
}
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:58,代码来源:company.lib.php

示例11:

 /**
  *		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;
     }
 }
开发者ID:ADDAdev,项目名称:Dolibarr,代码行数:26,代码来源:mod_codeclient_elephant.php

示例12: 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;
     }
 }
开发者ID:TAASA,项目名称:Dolibarr-ERP-3.8.1,代码行数:71,代码来源:html.formmail.class.php

示例13: 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
     }
 }
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:50,代码来源:mod_codecompta_aquarium.php

示例14: 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>';
}
开发者ID:ADDAdev,项目名称:Dolibarr,代码行数:53,代码来源:upgrade2.php

示例15: getIdAndTxFromCode

	 /**
	 * Get id and rate of currency from code 
	 * 
	 * @param DoliDB	$db		object db
	 * @param string	$code	code value search
	 * 
	 * @return 	array	[0] => id currency
	 *					[1] => rate
	 */
	 public static function getIdAndTxFromCode(&$db, $code)
	 {
	 	$sql = 'SELECT m.rowid, mc.rate FROM '.MAIN_DB_PREFIX.'multicurrency m';
		$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'multicurrency_rate mc ON (m.rowid = mc.fk_multicurrency)';
		$sql.= ' WHERE m.code = "'.$db->escape($code).'" AND mc.date_sync >= ALL (SELECT date_sync FROM '.MAIN_DB_PREFIX.'multicurrency_rate)';
		$resql = $db->query($sql);
		if ($resql && $obj = $db->fetch_object($resql)) return array($obj->rowid, $obj->rate);
		else return array(0, 1);
	 }
开发者ID:NoisyBoy86,项目名称:Dolibarr_test,代码行数:18,代码来源:multicurrency.class.php


注:本文中的DoliDB::query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。