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


PHP DoliDB::free方法代码示例

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


在下文中一共展示了DoliDB::free方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: pt

/**
 * print function
 *
 * @param   DoliDB $db          Database
 * @param   string $sql     sql
 * @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: vat_by_thirdparty

/**
 *  Look for collectable VAT clients in the chosen year (and month)
 *
 *  @param	DoliDB	$db          	Database handle
 *  @param  int		$y           	Year
 *  @param  string	$date_start  	Start date
 *  @param  string	$date_end    	End date
 *  @param  int		$modetax     	0 or 1 (option vat on debit, 1 => $modecompta = 'CREANCES-DETTES')
 *  @param  string	$direction   	'sell' or 'buy'
 *  @param  int		$m				Month
 *  @return array       			List of customers third parties with vat, -1 if no accountancy module, -2 if not yet developped, -3 if error
 */
function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction, $m = 0)
{
    global $conf;
    $list = array();
    if ($direction == 'sell') {
        $invoicetable = 'facture';
        $total_ht = 'total';
        $total_tva = 'tva';
    }
    if ($direction == 'buy') {
        $invoicetable = 'facture_fourn';
        $total_ht = 'total_ht';
        $total_tva = 'total_tva';
    }
    // Define sql request
    $sql = '';
    if ($modetax == 1) {
        // If vat paid on due invoices (non draft)
        $sql = "SELECT s.rowid as socid, s.nom as name, s.siren as tva_intra, s.tva_assuj as assuj,";
        $sql .= " sum(f.{$total_ht}) as amount, sum(f." . $total_tva . ") as tva,";
        $sql .= " sum(f.localtax1) as localtax1,";
        $sql .= " sum(f.localtax2) as localtax2";
        $sql .= " FROM " . MAIN_DB_PREFIX . $invoicetable . " as f,";
        $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,5)";
        } else {
            $sql .= " AND f.type IN (0,1,2,3,5)";
        }
        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";
        $sql .= " GROUP BY s.rowid, s.nom, s.tva_intra, s.tva_assuj";
    } else {
        // 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,5)";
        		else $sql.= " AND f.type IN (0,1,2,3,5)";
                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";
        */
    }
    if (!$sql) {
        return -1;
    }
    dol_syslog("Tax.lib:thirdparty", LOG_DEBUG);
    $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;
    }
}
开发者ID:Samara94,项目名称:dolibarr,代码行数:98,代码来源:tax.lib.php

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

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

示例5: 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.
//.........这里部分代码省略.........
开发者ID:TAASA,项目名称:Dolibarr-ERP-3.8.1,代码行数:101,代码来源:conf.class.php

示例6: 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

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

示例8: 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>";
}
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:77,代码来源:project.lib.php

示例9: show_actions_todo


//.........这里部分代码省略.........
        $sql .= " a.fk_user_author, a.fk_contact,";
        $sql .= " a.fk_element, a.elementtype,";
        $sql .= " c.code as acode, c.libelle,";
        $sql .= " u.login, u.rowid";
        if (get_class($object) == 'Adherent') {
            $sql .= ", m.lastname, m.firstname";
        }
        if (get_class($object) == 'Societe') {
            $sql .= ", sp.lastname, sp.firstname";
        }
        $sql .= " FROM " . MAIN_DB_PREFIX . "c_actioncomm as c, " . MAIN_DB_PREFIX . "user as u, " . MAIN_DB_PREFIX . "actioncomm as a";
        if (get_class($object) == 'Adherent') {
            $sql .= ", " . MAIN_DB_PREFIX . "adherent as m";
        }
        if (get_class($object) == 'Societe') {
            $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "socpeople as sp ON a.fk_contact = sp.rowid";
        }
        $sql .= " WHERE u.rowid = a.fk_user_author";
        $sql .= " AND a.entity IN (" . getEntity('agenda', 1) . ")";
        if (get_class($object) == 'Adherent') {
            $sql .= " AND a.fk_element = m.rowid AND a.elementtype = 'member'";
            if (!empty($object->id)) {
                $sql .= " AND a.fk_element = " . $object->id;
            }
        }
        if (get_class($object) == 'Societe' && $object->id) {
            $sql .= " AND a.fk_soc = " . $object->id;
        }
        if (!empty($objcon->id)) {
            $sql .= " AND a.fk_contact = " . $objcon->id;
        }
        $sql .= " AND c.id=a.fk_action";
        $sql .= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '" . $db->idate($now) . "'))";
        $sql .= " ORDER BY a.datep DESC, a.id DESC";
        dol_syslog("company.lib::show_actions_todo sql=" . $sql);
        $result = $db->query($sql);
        if ($result) {
            $i = 0;
            $num = $db->num_rows($result);
            $var = true;
            if ($num) {
                while ($i < $num) {
                    $var = !$var;
                    $obj = $db->fetch_object($result);
                    $datep = $db->jdate($obj->dp);
                    $out .= "<tr " . $bc[$var] . ">";
                    $out .= '<td width="120" align="left" class="nowrap">' . dol_print_date($datep, 'dayhour') . "</td>\n";
                    // Picto warning
                    $out .= '<td width="16">';
                    if ($obj->percent >= 0 && $datep && $datep < $now - $conf->global->MAIN_DELAY_ACTIONS_TODO * 60 * 60 * 24) {
                        $out .= ' ' . img_warning($langs->trans("Late"));
                    } else {
                        $out .= '&nbsp;';
                    }
                    $out .= '</td>';
                    $actionstatic->type_code = $obj->acode;
                    $transcode = $langs->trans("Action" . $obj->acode);
                    $libelle = $transcode != "Action" . $obj->acode ? $transcode : $obj->libelle;
                    //$actionstatic->libelle=$libelle;
                    $actionstatic->libelle = $obj->label;
                    $actionstatic->id = $obj->id;
                    //$out.='<td width="140">'.$actionstatic->getNomUrl(1,16).'</td>';
                    // Title of event
                    //$out.='<td colspan="2">'.dol_trunc($obj->label,40).'</td>';
                    $out .= '<td colspan="2">' . $actionstatic->getNomUrl(1, 40) . '</td>';
                    // Contact pour cette action
                    if (empty($objcon->id) && $obj->fk_contact > 0) {
                        $contactstatic->lastname = $obj->lastname;
                        $contactstatic->firstname = $obj->firstname;
                        $contactstatic->id = $obj->fk_contact;
                        $out .= '<td width="120">' . $contactstatic->getNomUrl(1, '', 10) . '</td>';
                    } else {
                        $out .= '<td>&nbsp;</td>';
                    }
                    $out .= '<td width="80" class="nowrap">';
                    $userstatic->id = $obj->fk_user_author;
                    $userstatic->login = $obj->login;
                    $out .= $userstatic->getLoginUrl(1);
                    $out .= '</td>';
                    // Statut
                    $out .= '<td class="nowrap" width="20">' . $actionstatic->LibStatut($obj->percent, 3) . '</td>';
                    $out .= "</tr>\n";
                    $i++;
                }
            } else {
                // Aucun action a faire
            }
            $db->free($result);
        } else {
            dol_print_error($db);
        }
        $out .= "</table>\n";
        $out .= "<br>\n";
    }
    if ($noprint) {
        return $out;
    } else {
        print $out;
    }
}
开发者ID:LionSystemsSolutions,项目名称:El-Canelo-ERP,代码行数:101,代码来源:company.lib.php

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

示例11: migrate_price_commande_fournisseur

/**
 * Mise a jour des totaux lignes de commande fournisseur
 *
 * @param	DoliDB		$db		Database handler
 * @param	Translate	$langs	Object langs
 * @param	Conf		$conf	Object conf
 * @return	void
 */
function migrate_price_commande_fournisseur($db, $langs, $conf)
{
    $db->begin();
    print '<tr><td colspan="4">';
    print '<br>';
    print '<b>' . $langs->trans('MigrationSupplierOrder') . "</b><br>\n";
    // Liste des lignes commande non a jour
    $sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as tva_taux, cd.info_bits,";
    $sql .= " c.rowid as commandeid, c.remise_percent as remise_percent_global";
    $sql .= " FROM " . MAIN_DB_PREFIX . "commande_fournisseurdet as cd, " . MAIN_DB_PREFIX . "commande_fournisseur as c";
    $sql .= " WHERE cd.fk_commande = c.rowid";
    $sql .= " AND ((cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL)";
    dolibarr_install_syslog("upgrade2::migrate_price_commande_fournisseur", LOG_DEBUG);
    $resql = $db->query($sql);
    if ($resql) {
        $num = $db->num_rows($resql);
        $i = 0;
        if ($num) {
            while ($i < $num) {
                $obj = $db->fetch_object($resql);
                $rowid = $obj->rowid;
                $qty = $obj->qty;
                $pu = $obj->subprice;
                $txtva = $obj->tva_taux;
                $remise_percent = $obj->remise_percent;
                $remise_percent_global = $obj->remise_percent_global;
                $info_bits = $obj->info_bits;
                // On met a jour les 3 nouveaux champs
                $commandeligne = new CommandeFournisseurLigne($db);
                $commandeligne->fetch($rowid);
                $result = calcul_price_total($qty, $pu, $remise_percent, $txtva, 0, 0, $remise_percent_global, 'HT', $info_bits, 0);
                $total_ht = $result[0];
                $total_tva = $result[1];
                $total_ttc = $result[2];
                $commandeligne->total_ht = $total_ht;
                $commandeligne->total_tva = $total_tva;
                $commandeligne->total_ttc = $total_ttc;
                dolibarr_install_syslog("upgrade2: Line {$rowid}: commandeid={$obj->rowid} pu={$pu} qty={$qty} tva_taux={$txtva} remise_percent={$remise_percent} remise_global={$remise_percent_global} -> {$total_ht}, {$total_tva}, {$total_ttc}");
                print ". ";
                $commandeligne->update_total();
                /* On touche pas a facture mere
                   $commande = new Commande($db);
                   $commande->id = $obj->rowid;
                   if ( $commande->fetch($commande->id) >= 0 )
                   {
                   if ( $commande->update_price() > 0 )
                   {
                   print ". ";
                   }
                   else
                   {
                   print "Error id=".$commande->id;
                   }
                   }
                   else
                   {
                   print "Error #3";
                   }
                   */
                $i++;
            }
        } else {
            print $langs->trans("AlreadyDone");
        }
        $db->free($resql);
        /*
        $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet";
        $sql.= " WHERE subprice = 0 and total_ttc = 0 and total_tva = 0 and total_ht = 0";
        $resql=$db->query($sql);
        if (! $resql)
        {
        dol_print_error($db);
        }
        */
        $db->commit();
    } else {
        print "Error #1 " . $db->error();
        $db->rollback();
    }
    print '<br>';
    print '</td></tr>';
}
开发者ID:ADDAdev,项目名称:Dolibarr,代码行数:90,代码来源:upgrade2.php

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

示例13: 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
 * @param	int		$statut				-1=No filter on statut, 0 or 1 = Filter on status
 * @return	void
 */
function print_projecttasks_array($db, $socid, $projectsListId, $mytasks = 0, $statut = -1)
{
    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("Project");
    if ($statut == 0) {
        $title = $langs->trans("ProjectDraft");
    }
    if ($statut == 1) {
        $title = $langs->trans("Project") . ' (' . $langs->trans("Validated") . ')';
    }
    print '<table class="noborder" width="100%">';
    print '<tr class="liste_titre">';
    print_liste_field_titre($title, "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;
    }
    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";
    $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>";
//.........这里部分代码省略.........
开发者ID:ADDAdev,项目名称:Dolibarr,代码行数:101,代码来源:project.lib.php


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