diff --git a/htdocs/compta/stats/cumul.php b/htdocs/compta/stats/cumul.php index d06b7ac3dd0..0b7366c5455 100644 --- a/htdocs/compta/stats/cumul.php +++ b/htdocs/compta/stats/cumul.php @@ -91,33 +91,35 @@ function pt ($db, $sql, $date) $bc[1]="class=\"impair\""; $result = $db->query($sql); - if ($result) { - $num = $db->num_rows(); - $i = 0; $total = 0 ; - print ''; - print ""; - print ""; - print ""; - print "\n"; - print "\n"; - $var=True; - while ($i < $num) { - $obj = $db->fetch_object( $i); - $var=!$var; - print ""; - print "\n"; - print "\n"; + if ($result) + { + $num = $db->num_rows(); + $i = 0; $total = 0 ; + print '
$dateMontant 
$obj->dm".price($obj->amount)." 
'; + print ""; + print ""; + print ""; + print "\n"; print "\n"; + $var=True; + while ($i < $num) + { + $obj = $db->fetch_object( $i); + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + + $total = $total + $obj->amount; - $total = $total + $obj->amount; + $i++; + } + print ''; - $i++; + print "
$dateMontant 
$obj->dm".price($obj->amount)." 
Total :'.price($total).''.MAIN_MONNAIE.' HT
"; + $db->free(); } - print 'Total :'.price($total).'euros HT'; - - print ""; - $db->free(); - } } diff --git a/htdocs/compta/stats/index.php b/htdocs/compta/stats/index.php index ed7cb9d0d97..cb46cbc73c3 100644 --- a/htdocs/compta/stats/index.php +++ b/htdocs/compta/stats/index.php @@ -35,7 +35,7 @@ if ($user->societe_id > 0) $socidp = $user->societe_id; } -print_titre("Chiffres d'affaires en euros HT"); +print_titre("Chiffres d'affaires (".MAIN_MONNAIE." HT)"); $sql = "SELECT sum(f.total) as amount , date_format(f.datef,'%Y-%m') as dm"; $sql .= " FROM llx_facture as f WHERE f.paye = 1"; @@ -59,7 +59,7 @@ if ($result) } } -print ''; +print '
'; print ''; diff --git a/htdocs/compta/stats/prev.php b/htdocs/compta/stats/prev.php index e13bebcd7eb..b28f72561c9 100644 --- a/htdocs/compta/stats/prev.php +++ b/htdocs/compta/stats/prev.php @@ -33,8 +33,8 @@ if ($user->societe_id > 0) function pt ($db, $sql, $title) { global $bc; - print '
 
'; - print ""; + print '
'; + print ''; print ""; print ""; @@ -58,7 +58,7 @@ function pt ($db, $sql, $title) { $total = $total + $obj->amount; $i++; } - print ""; + print ""; $db->free(); } diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 57c8b337ae6..cb88deed4ab 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -69,37 +69,50 @@ class Product */ Function create($user) { - if (strlen($this->price)==0) - { - $this->price = 0; - } - $this->price = round($this->price, 2); + $sql = "SELECT count(*)"; + $sql .= " FROM llx_product WHERE ref = '" .trim($this->ref)."'"; + + $result = $this->db->query($sql) ; - $sql = "INSERT INTO llx_product (datec, fk_user_author, fk_product_type, price)"; - $sql .= " VALUES (now(),".$user->id.",$this->type, " . ereg_replace(",",".",$this->price) . ")"; - $result = $this->db->query($sql); if ( $result ) { - $id = $this->db->last_insert_id(); - - if ($id > 0) + $row = $this->db->fetch_array(); + if ($row[0] == 0) { - $this->id = $id; - $this->_log_price($user); - if ( $this->update($id, $user) ) + + if (strlen($this->price)==0) { - return $id; + $this->price = 0; + } + $this->price = round($this->price, 2); + + $sql = "INSERT INTO llx_product (datec, fk_user_author, fk_product_type, price)"; + $sql .= " VALUES (now(),".$user->id.",$this->type, " . ereg_replace(",",".",$this->price) . ")"; + $result = $this->db->query($sql); + if ( $result ) + { + $id = $this->db->last_insert_id(); + + if ($id > 0) + { + $this->id = $id; + $this->_log_price($user); + if ( $this->update($id, $user) ) + { + return $id; + } + } + else + { + return -2; + } + } + else + { + print $this->db->error() . ' in ' . $sql; + return -1; } } - else - { - return -2; - } - } - else - { - print $this->db->error() . ' in ' . $sql; - return -1; } } /* @@ -197,8 +210,7 @@ class Product * */ Function fetch ($id) - { - + { $sql = "SELECT rowid, ref, label, description, price, tva_tx, envente, nbvente, fk_product_type, duration"; $sql .= " FROM llx_product WHERE rowid = $id"; diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 084b8b52b33..04863135cc5 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -40,14 +40,14 @@ if ($action == 'add') { $product = new Product($db); - $product->ref = $HTTP_POST_VARS["ref"]; - $product->libelle = $HTTP_POST_VARS["libelle"]; - $product->price = $HTTP_POST_VARS["price"]; - $product->tva_tx = $HTTP_POST_VARS["tva_tx"]; - $product->type = $HTTP_POST_VARS["type"]; - $product->description = $HTTP_POST_VARS["desc"]; + $product->ref = $HTTP_POST_VARS["ref"]; + $product->libelle = $HTTP_POST_VARS["libelle"]; + $product->price = $HTTP_POST_VARS["price"]; + $product->tva_tx = $HTTP_POST_VARS["tva_tx"]; + $product->type = $HTTP_POST_VARS["type"]; + $product->description = $HTTP_POST_VARS["desc"]; $product->duration_value = $HTTP_POST_VARS["duration_value"]; - $product->duration_unit = $HTTP_POST_VARS["duration_unit"]; + $product->duration_unit = $HTTP_POST_VARS["duration_unit"]; $id = $product->create($user); $action = '';
$titleMontant
Total : ".price($total)." euros HT
Total : ".price($total)." ".MAIN_MONNAIE." HT