2
0
forked from Wavyzz/dolibarr
Files
dolibarr-fork/doc/dev/php/html/price_8lib_8php-source.html
2004-07-15 18:43:48 +00:00

101 lines
4.7 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>dolibarr: htdocs/lib/price.lib.php Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Généré par Doxygen 1.3.7 -->
<div class="qindex"><a class="qindex" href="index.html">Page&nbsp;principale</a> | <a class="qindex" href="classes.html">Liste&nbsp;alphabétique</a> | <a class="qindex" href="annotated.html">Liste&nbsp;des&nbsp;classes</a> | <a class="qindex" href="files.html">Liste&nbsp;des&nbsp;fichiers</a> | <a class="qindex" href="functions.html">Membres&nbsp;de&nbsp;classe</a> | <a class="qindex" href="globals.html">Membres&nbsp;de&nbsp;fichier</a></div>
<h1>htdocs/lib/price.lib.php</h1><a href="price_8lib_8php.html">Aller à la documentation de ce fichier.</a><pre class="fragment"><div>00001 &lt;?PHP
00002 <span class="comment">/* Copyright (C) 2002-2003 Rodolphe Quiedeville &lt;rodolphe@quiedeville.org&gt;</span>
00003 <span class="comment"> *</span>
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
00005 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
00006 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
00007 <span class="comment"> * (at your option) any later version.</span>
00008 <span class="comment"> *</span>
00009 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
00010 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
00011 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
00012 <span class="comment"> * GNU General Public License for more details.</span>
00013 <span class="comment"> *</span>
00014 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
00015 <span class="comment"> * along with this program; if not, write to the Free Software</span>
00016 <span class="comment"> * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.</span>
00017 <span class="comment"> *</span>
00018 <span class="comment"> * $Id$</span>
00019 <span class="comment"> * $Source$</span>
00020 <span class="comment"> *</span>
00021 <span class="comment"> */</span>
00022
<a name="l00038"></a><a class="code" href="price_8lib_8php.html#a0">00038</a> function <a class="code" href="price_8lib_8php.html#a0">calcul_price</a>($products, $remise_percent)
00039 {
00040 $total_ht = 0;
00041 $amount_ht = 0;
00042 $tva = array();
00043 $total_tva = 0;
00044 $total_remise = 0;
00045
00046 $num = <span class="keyword">sizeof</span>($products);
00047 $i = 0;
00048
00049 <span class="keywordflow">while</span> ($i &lt; $num)
00050 {
00051 $prod_price = $products[$i][0];
00052 $prod_qty = $products[$i][1];
00053 $prod_txtva = $products[$i][2];
00054
00055 $lprice = $prod_qty * $prod_price;
00056
00057 $amount_ht = $amount_ht + $lprice;
00058
00059 <span class="keywordflow">if</span> ($remise_percent &gt; 0)
00060 {
00061 $lremise = ($lprice * $remise_percent / 100);
00062 $lprice = $lprice - $lremise;
00063 $total_remise = $total_remise + $lremise;
00064 }
00065
00066 $total_ht = $total_ht + $lprice;
00067
00068 $ligne_tva = ($lprice * ($prod_txtva / 100));
00069
00070 $tva[$prod_txtva] = $tva[$prod_txtva] + $ligne_tva;
00071 $i++;
00072 }
00073
00074 <span class="comment">/*</span>
00075 <span class="comment"> * Sommes et arrondis</span>
00076 <span class="comment"> */</span>
00077 $j=0;
00078 $result[5] = array();
00079
00080 foreach ($tva as $key =&gt; $value)
00081 {
00082 $tva[$key] = round($tva[$key], 2);
00083 $total_tva = $total_tva + $tva[$key];
00084 $result[5][$key] = $tva[$key];
00085 $j++;
00086 }
00087
00088 $total_ht = round($total_ht, 2);
00089 $total_tva = round($total_tva, 2);
00090
00091 $total_ttc = $total_ht + $total_tva;
00092
00093 <span class="comment">/*</span>
00094 <span class="comment"> *</span>
00095 <span class="comment"> */</span>
00096 $result[0] = $total_ht;
00097 $result[1] = $total_tva;
00098 $result[2] = $total_ttc;
00099 $result[3] = $total_remise;
00100 $result[4] = $amount_ht;
00101
00102 <span class="keywordflow">return</span> $result;
00103 }
</div></pre><hr size="1"><address style="align: right;"><small>Généré le Thu Jul 15 20:50:38 2004 pour dolibarr par
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.7 </small></address>
</body>
</html>