diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php
index 82c3ec3ca10..e6ada14a7db 100644
--- a/htdocs/accountancy/class/accountingaccount.class.php
+++ b/htdocs/accountancy/class/accountingaccount.class.php
@@ -18,7 +18,7 @@
*/
/**
- * \file htdocs/accountancy/class/Accountingaccount.class.php
+ * \file htdocs/accountancy/class/accountingaccount.class.php
* \ingroup Accounting Expert
* \brief Fichier de la classe des comptes comptable
*/
@@ -29,8 +29,11 @@
class AccountingAccount
{
var $db;
+ var $error;
+
var $id;
var $rowid;
+
var $datec; // Creation date
var $fk_pcg_version;
var $pcg_type;
@@ -62,8 +65,10 @@ class AccountingAccount
*/
function fetch($rowid = null, $account_number = null)
{
- if ($rowid || $account_number) {
- $sql = "SELECT * FROM " . MAIN_DB_PREFIX . "accountingaccount WHERE ";
+ if ($rowid || $account_number)
+ {
+ $sql = "SELECT rowid, datec, tms, fk_pcg_version, pcg_type, pcg_subtype, account_number, account_parent, labe, fk_user_author, fk_user_modifn active";
+ $sql.= " FROM " . MAIN_DB_PREFIX . "accountingaccount WHERE";
if ($rowid) {
$sql .= " rowid = '" . $rowid . "'";
} elseif ($account_number) {
@@ -72,28 +77,40 @@ class AccountingAccount
dol_syslog(get_class($this) . "::fetch sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql);
- if ($result) {
+ if ($result)
+ {
$obj = $this->db->fetch_object($result);
- } else {
- return null;
+
+ if ($obj)
+ {
+ $this->id = $obj->rowid;
+ $this->rowid = $obj->rowid;
+ $this->datec = $obj->datec;
+ $this->tms = $obj->tms;
+ $this->fk_pcg_version = $obj->fk_pcg_version;
+ $this->pcg_type = $obj->pcg_type;
+ $this->pcg_subtype = $obj->pcg_subtype;
+ $this->account_number = $obj->account_number;
+ $this->account_parent = $obj->account_parent;
+ $this->label = $obj->label;
+ $this->fk_user_author = $obj->fk_user_author;
+ $this->fk_user_modif = $obj->fk_user_modif;
+ $this->active = $obj->active;
+
+ return $this->id;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ else
+ {
+ dol_print_error($this->db);
}
}
- $this->id = $obj->rowid;
- $this->rowid = $obj->rowid;
- $this->datec = $obj->datec;
- $this->tms = $obj->tms;
- $this->fk_pcg_version = $obj->fk_pcg_version;
- $this->pcg_type = $obj->pcg_type;
- $this->pcg_subtype = $obj->pcg_subtype;
- $this->account_number = $obj->account_number;
- $this->account_parent = $obj->account_parent;
- $this->label = $obj->label;
- $this->fk_user_author = $obj->fk_user_author;
- $this->fk_user_modif = $obj->fk_user_modif;
- $this->active = $obj->active;
-
- return $obj->rowid;
+ return -1;
}
/**
diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php
index e0c2ceb8e36..c9d21f5d9be 100644
--- a/htdocs/accountancy/journal/purchasesjournal.php
+++ b/htdocs/accountancy/journal/purchasesjournal.php
@@ -28,7 +28,7 @@
*/
require '../../main.inc.php';
-
+
// Class
require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
@@ -88,12 +88,12 @@ $sql = "SELECT f.rowid, f.ref, f.type, f.datef as df, f.libelle,";
$sql .= " fd.rowid as fdid, fd.description, fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_type,";
$sql .= " s.rowid as socid, s.nom as name, s.code_compta_fournisseur, s.fournisseur,";
$sql .= " s.code_compta_fournisseur, p.accountancy_code_buy , ct.accountancy_code_buy as account_tva, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
-$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det fd";
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'";
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product p ON p.rowid = fd.fk_product";
-$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount aa ON aa.rowid = fd.fk_code_ventilation";
-$sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn f ON f.rowid = fd.fk_facture_fourn";
-$sql .= " JOIN " . MAIN_DB_PREFIX . "societe s ON s.rowid = f.fk_soc";
+$sql .= " FROM " . MAIN_DB_PREFIX . "facture_fourn_det as fd";
+$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_tva as ct ON fd.tva_tx = ct.taux AND ct.fk_pays = '" . $idpays . "'";
+$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = fd.fk_product";
+$sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON aa.rowid = fd.fk_code_ventilation";
+$sql .= " JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = fd.fk_facture_fourn";
+$sql .= " JOIN " . MAIN_DB_PREFIX . "societe as s ON s.rowid = f.fk_soc";
$sql .= " WHERE f.fk_statut > 0 ";
if (! empty($conf->multicompany->enabled)) {
$sql .= " AND f.entity = " . $conf->entity;
@@ -113,13 +113,13 @@ if ($result) {
// les variables
$cptfour = (! empty($conf->global->COMPTA_ACCOUNT_SUPPLIER)) ? $conf->global->COMPTA_ACCOUNT_SUPPLIER : $langs->trans("CodeNotDef");
$cpttva = (! empty($conf->global->COMPTA_VAT_ACCOUNT)) ? $conf->global->COMPTA_VAT_ACCOUNT : $langs->trans("CodeNotDef");
-
+
$tabfac = array ();
$tabht = array ();
$tabtva = array ();
$tabttc = array ();
$tabcompany = array ();
-
+
$i = 0;
while ( $i < $num ) {
$obj = $db->fetch_object($result);
@@ -133,7 +133,7 @@ if ($result) {
$compta_prod = (! empty($conf->global->COMPTA_SERVICE_BUY_ACCOUNT)) ? $conf->global->COMPTA_SERVICE_BUY_ACCOUNT : $langs->trans("CodeNotDef");
}
$compta_tva = (! empty($obj->account_tva) ? $obj->account_tva : $cpttva);
-
+
$tabfac[$obj->rowid]["date"] = $obj->df;
$tabfac[$obj->rowid]["ref"] = $obj->ref;
$tabfac[$obj->rowid]["type"] = $obj->type;
@@ -145,9 +145,9 @@ if ($result) {
$tabcompany[$obj->rowid] = array (
'id' => $obj->socid,
'name' => $obj->name,
- 'code_fournisseur' => $obj->code_compta_fournisseur
+ 'code_fournisseur' => $obj->code_compta_fournisseur
);
-
+
$i ++;
}
} else {
@@ -160,11 +160,11 @@ if ($result) {
// Bookkeeping Write
if ($action == 'writebookkeeping') {
$now = dol_now();
-
+
foreach ( $tabfac as $key => $val ) {
foreach ( $tabttc[$key] as $k => $mt ) {
// get compte id and label
-
+
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
@@ -180,10 +180,10 @@ if ($action == 'writebookkeeping') {
$bookkeeping->debit = ($mt <= 0) ? $mt : 0;
$bookkeeping->credit = ($mt > 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
-
+
$bookkeeping->create();
}
-
+
// Product / Service
foreach ( $tabht[$key] as $k => $mt ) {
if ($mt) {
@@ -205,18 +205,18 @@ if ($action == 'writebookkeeping') {
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
-
+
$bookkeeping->create();
}
}
}
-
+
// VAT
// var_dump($tabtva);
foreach ( $tabtva[$key] as $k => $mt ) {
if ($mt) {
// get compte id and label
-
+
$bookkeeping = new BookKeeping($db);
$bookkeeping->doc_date = $val["date"];
$bookkeeping->doc_ref = $val["ref"];
@@ -232,7 +232,7 @@ if ($action == 'writebookkeeping') {
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
$bookkeeping->code_journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
-
+
$bookkeeping->create();
}
}
@@ -243,21 +243,21 @@ if ($action == 'writebookkeeping') {
if ($action == 'export_csv') {
$sep = $conf->global->ACCOUNTING_SEPARATORCSV;
-
+
header('Content-Type: text/csv');
header('Content-Disposition: attachment;filename=journal_achats.csv');
-
+
if ($conf->global->ACCOUNTING_MODELCSV == 1) // Modèle Export Cegid Expert
{
foreach ( $tabfac as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), '%d%m%Y');
-
+
// Product / Service
foreach ( $tabht[$key] as $k => $mt ) {
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];
-
+
if ($mt) {
print $date . $sep;
print $conf->global->ACCOUNTING_PURCHASE_JOURNAL . $sep;
@@ -270,7 +270,7 @@ if ($action == 'export_csv') {
print "\n";
}
}
-
+
// VAT
// var_dump($tabtva);
foreach ( $tabtva[$key] as $k => $mt ) {
@@ -289,7 +289,7 @@ if ($action == 'export_csv') {
print $date . $sep;
print $conf->global->ACCOUNTING_PURCHASE_JOURNAL . $sep;
print length_accountg($conf->global->COMPTA_ACCOUNT_SUPPLIER) . $sep;
-
+
foreach ( $tabttc[$key] as $k => $mt ) {
print length_accounta(html_entity_decode($k)) . $sep;
print ($mt < 0 ? 'D' : 'C') . $sep;
@@ -303,11 +303,11 @@ if ($action == 'export_csv') {
{
foreach ( $tabfac as $key => $val ) {
$date = dol_print_date($db->jdate($val["date"]), 'day');
-
+
$companystatic->id = $tabcompany[$key]['id'];
$companystatic->name = $tabcompany[$key]['name'];
$companystatic->client = $tabcompany[$key]['code_client'];
-
+
// Product / Service
foreach ( $tabht[$key] as $k => $mt ) {
if ($mt) {
@@ -333,7 +333,7 @@ if ($action == 'export_csv') {
print "\n";
}
}
-
+
// Third party
print '"' . $date . '"' . $sep;
print '"' . $val["ref"] . '"' . $sep;
@@ -347,11 +347,11 @@ if ($action == 'export_csv') {
}
}
} else {
-
+
llxHeader('', '', '');
-
+
$form = new Form($db);
-
+
$nom = $langs->trans("PurchasesJournal");
$nomlink = '';
$periodlink = '';
@@ -364,11 +364,11 @@ if ($action == 'export_csv') {
$description .= $langs->trans("DepositsAreIncluded");
$period = $form->select_date($date_start, 'date_start', 0, 0, 0, '', 1, 0, 1) . ' - ' . $form->select_date($date_end, 'date_end', 0, 0, 0, '', 1, 0, 1);
report_header($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''));
-
+
print '';
-
+
print '';
-
+
print '
';
-
+
/*
* Show result array
*/
print '
';
-
+
$i = 0;
print "
| " . $langs->trans("Account") . " | "; print "" . $langs->trans("Type") . " | " . $langs->trans("Debit") . " | " . $langs->trans("Credit") . " | "; print "||
| ".$conf->global->COMPTA_JOURNAL_BUY." | "; print "" . $date . " | "; print "" . $invoicestatic->getNomUrl(1) . " | "; - + foreach ( $tabttc[$key] as $k => $mt ) { $companystatic->id = $tabcompany[$key]['id']; $companystatic->name = $tabcompany[$key]['name']; - + print "" . length_accounta($k); print " | " . $langs->trans("ThirdParty"); print ' (' . $companystatic->getNomUrl(0, 'supplier', 16) . ')'; @@ -459,12 +459,12 @@ if ($action == 'export_csv') { print ' | ' . ($mt >= 0 ? price($mt) : '') . " | "; } print "
| '.$langs->trans("ActionDoneBy").' | '; print $form->select_dolusers($object->userdone->id> 0?$object->userdone->id:-1,'doneby',1); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index c46f48ed1c6..c4b548c7e81 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -484,7 +484,7 @@ class Facture extends CommonInvoice // Call trigger $result=$this->call_trigger('BILL_CREATE',$user); - if ($result < 0) $error++; + if ($result < 0) $error++; // End call triggers if (! $error) @@ -593,8 +593,8 @@ class Facture extends CommonInvoice // Load source object $objFrom = dol_clone($this); - - + + // Change socid if needed if (! empty($socid) && $socid != $this->socid) @@ -637,7 +637,7 @@ class Facture extends CommonInvoice unset($this->products[$i]); // Tant que products encore utilise } } - + // Create clone $result=$this->create($user); if ($result < 0) $error++; @@ -645,7 +645,7 @@ class Facture extends CommonInvoice // copy internal contacts if ($this->copy_linked_contact($objFrom, 'internal') < 0) $error++; - + // copy external contacts if same company elseif ($objFrom->socid == $this->socid) { @@ -667,7 +667,7 @@ class Facture extends CommonInvoice // Call trigger $result=$this->call_trigger('BILL_CLONE',$user); - if ($result < 0) $error++; + if ($result < 0) $error++; // End call triggers } @@ -1108,7 +1108,7 @@ class Facture extends CommonInvoice { // Call trigger $result=$this->call_trigger('BILL_MODIFY',$user); - if ($result < 0) $error++; + if ($result < 0) $error++; // End call triggers } } @@ -1266,7 +1266,7 @@ class Facture extends CommonInvoice { // Call trigger $result=$this->call_trigger('BILL_DELETE',$user); - if ($result < 0) $error++; + if ($result < 0) $error++; // End call triggers } @@ -1438,7 +1438,7 @@ class Facture extends CommonInvoice { // Call trigger $result=$this->call_trigger('BILL_PAYED',$user); - if ($result < 0) $error++; + if ($result < 0) $error++; // End call triggers } else @@ -1490,7 +1490,7 @@ class Facture extends CommonInvoice { // Call trigger $result=$this->call_trigger('BILL_UNPAYED',$user); - if ($result < 0) $error++; + if ($result < 0) $error++; // End call triggers } else @@ -1554,7 +1554,7 @@ class Facture extends CommonInvoice // Call trigger $result=$this->call_trigger('BILL_CANCEL',$user); if ($result < 0) - { + { $this->db->rollback(); return -1; } @@ -1768,11 +1768,11 @@ class Facture extends CommonInvoice { // Call trigger $result=$this->call_trigger('BILL_VALIDATE',$user); - if ($result < 0) $error++; - //TODO: Restoring ref, facnumber, statut, brouillon to previous value if trigger fail + if ($result < 0) $error++; + //TODO: Restoring ref, facnumber, statut, brouillon to previous value if trigger fail // End call triggers } - + // Set new ref and define current statut if (! $error) { @@ -1856,7 +1856,7 @@ class Facture extends CommonInvoice $this->statut = 0; // Call trigger $result=$this->call_trigger('BILL_UNVALIDATE',$user); - if ($result < 0) + if ($result < 0) { $error++; $this->statut=$old_statut; @@ -3164,7 +3164,7 @@ class Facture extends CommonInvoice $sql.= ' p.ref as product_ref, p.fk_product_type, p.label as product_label,'; $sql.= ' p.description as product_desc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l'; - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product p ON l.fk_product=p.rowid'; + $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product=p.rowid'; $sql.= ' WHERE l.fk_facture = '.$this->id; $sql.= ' ORDER BY l.rang ASC, l.rowid'; @@ -3550,7 +3550,7 @@ class FactureLigne extends CommonInvoiceLine // Call trigger $result=$this->call_trigger('LINEBILL_INSERT',$user); if ($result < 0) - { + { $this->db->rollback(); return -2; } @@ -3661,7 +3661,7 @@ class FactureLigne extends CommonInvoiceLine { // Call trigger $result=$this->call_trigger('LINEBILL_UPDATE',$user); - if ($result < 0) + if ($result < 0) { $this->db->rollback(); return -2; @@ -3691,7 +3691,7 @@ class FactureLigne extends CommonInvoiceLine $error=0; $this->db->begin(); - + // Call trigger $result=$this->call_trigger('LINEBILL_DELETE',$user); if ($result < 0) @@ -3700,7 +3700,7 @@ class FactureLigne extends CommonInvoiceLine return -1; } // End call triggers - + $sql = "DELETE FROM ".MAIN_DB_PREFIX."facturedet WHERE rowid = ".$this->rowid; dol_syslog(get_class($this)."::delete", LOG_DEBUG); diff --git a/htdocs/compta/journal/purchasesjournal.php b/htdocs/compta/journal/purchasesjournal.php index 81ceeb6f39d..169fb32010a 100644 --- a/htdocs/compta/journal/purchasesjournal.php +++ b/htdocs/compta/journal/purchasesjournal.php @@ -104,11 +104,11 @@ $sql.= " fd.total_ttc, fd.tva_tx, fd.total_ht, fd.tva as total_tva, fd.product_t $sql.= " s.rowid as socid, s.nom as name, s.code_compta_fournisseur,"; $sql.= " p.rowid as pid, p.ref as ref, p.accountancy_code_buy,"; $sql.= " ct.accountancy_code_buy as account_tva, ct.recuperableonly"; -$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det fd"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND fd.info_bits = ct.recuperableonly AND ct.fk_pays = '".$idpays."'"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = fd.fk_product"; -$sql.= " JOIN ".MAIN_DB_PREFIX."facture_fourn f ON f.rowid = fd.fk_facture_fourn"; -$sql.= " JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid = f.fk_soc" ; +$sql.= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as fd"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva as ct ON fd.tva_tx = ct.taux AND fd.info_bits = ct.recuperableonly AND ct.fk_pays = '".$idpays."'"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; +$sql.= " JOIN ".MAIN_DB_PREFIX."facture_fourn as f ON f.rowid = fd.fk_facture_fourn"; +$sql.= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc" ; $sql.= " WHERE f.fk_statut > 0 AND f.entity = ".$conf->entity; 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)"; diff --git a/htdocs/compta/journal/sellsjournal.php b/htdocs/compta/journal/sellsjournal.php index 6e65446bdda..f90add66b54 100644 --- a/htdocs/compta/journal/sellsjournal.php +++ b/htdocs/compta/journal/sellsjournal.php @@ -105,10 +105,10 @@ $sql.= " fd.product_type, fd.total_ht, fd.total_tva, fd.tva_tx, fd.total_ttc, fd $sql.= " s.rowid as socid, s.nom as name, s.code_compta, s.client,"; $sql.= " p.rowid as pid, p.ref as pref, p.accountancy_code_sell,"; $sql.= " ct.accountancy_code_sell as account_tva, ct.recuperableonly"; -$sql.= " FROM ".MAIN_DB_PREFIX."facturedet fd"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product p ON p.rowid = fd.fk_product"; -$sql.= " JOIN ".MAIN_DB_PREFIX."facture f ON f.rowid = fd.fk_facture"; -$sql.= " JOIN ".MAIN_DB_PREFIX."societe s ON s.rowid = f.fk_soc"; +$sql.= " FROM ".MAIN_DB_PREFIX."facturedet as fd"; +$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON p.rowid = fd.fk_product"; +$sql.= " JOIN ".MAIN_DB_PREFIX."facture as f ON f.rowid = fd.fk_facture"; +$sql.= " JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = f.fk_soc"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_tva ct ON fd.tva_tx = ct.taux AND fd.info_bits = ct.recuperableonly AND ct.fk_pays = '".$idpays."'"; $sql.= " WHERE f.entity = ".$conf->entity; $sql.= " AND f.fk_statut > 0"; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 153ff769eb6..331705f0b3f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1289,7 +1289,7 @@ class Form * @return string HTML select string * @see select_dolgroups */ - function select_dolusers_forevent($htmlname='userid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='') + function select_dolusers_forevent($action='', $htmlname='userid', $show_empty=0, $exclude='', $disabled=0, $include='', $enableonly='', $force_entity=0, $maxlength=0, $showstatus=0, $morefilter='') { global $conf,$user,$langs; @@ -1297,18 +1297,24 @@ class Form // Method with no ajax //$out.=''; diff --git a/htdocs/product/stock/class/entrepot.class.php b/htdocs/product/stock/class/entrepot.class.php index 78d4cc55a4e..9d1c138bc5f 100644 --- a/htdocs/product/stock/class/entrepot.class.php +++ b/htdocs/product/stock/class/entrepot.class.php @@ -186,12 +186,12 @@ class Entrepot extends CommonObject $sql = "DELETE FROM ".MAIN_DB_PREFIX."stock_mouvement"; $sql.= " WHERE fk_entrepot = " . $this->id; - dol_syslog("Entrepot::delete", LOG_DEBUG); + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql1=$this->db->query($sql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."product_stock"; $sql.= " WHERE fk_entrepot = " . $this->id; - dol_syslog("Entrepot::delete", LOG_DEBUG); + dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql2=$this->db->query($sql); if ($resql1 && $resql2) @@ -202,8 +202,8 @@ class Entrepot extends CommonObject dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql1=$this->db->query($sql); - // Update denormalized fields because we change content of produt_stock - $sql = "UPDATE ".MAIN_DB_PREFIX."product p SET p.stock= (SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock ps WHERE ps.fk_product = p.rowid)"; + // Update denormalized fields because we change content of produt_stock. Warning: Do not use "SET p.stock", does not works with pgsql + $sql = "UPDATE ".MAIN_DB_PREFIX."product as p SET stock = (SELECT SUM(ps.reel) FROM ".MAIN_DB_PREFIX."product_stock as ps WHERE ps.fk_product = p.rowid)"; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql2=$this->db->query($sql); @@ -217,7 +217,7 @@ class Entrepot extends CommonObject { $this->db->rollback(); $this->error=$this->db->lasterror(); - return -1; + return -2; } } else @@ -540,7 +540,7 @@ class Entrepot extends CommonObject $this->description = 'WAREHOUSE SPECIMEN '.dol_print_date($now,'dayhourlog'); $this->statut=1; $this->specimen=1; - + $this->lieu='Location test'; $this->address='21 jump street'; $this->zip='99999'; diff --git a/htdocs/product/stock/fiche.php b/htdocs/product/stock/fiche.php index 86e930d8cf1..1155ef6cb40 100644 --- a/htdocs/product/stock/fiche.php +++ b/htdocs/product/stock/fiche.php @@ -261,7 +261,7 @@ else // Country print ' | ||
| '.$langs->trans('Country').' | '; - if (! empty($object->country_code)) + if (! empty($object->country_code)) { $img=picto_from_langcode($object->country_code); print ($img?$img.' ':''); @@ -339,14 +339,14 @@ else print "id."\">".$langs->trans("Modify").""; else print "".$langs->trans("Modify").""; - + if ($user->rights->stock->supprimer) print "id."\">".$langs->trans("Delete").""; else print "".$langs->trans("Delete").""; } } - + print ""; @@ -375,7 +375,7 @@ else $sql = "SELECT p.rowid as rowid, p.ref, p.label as produit, p.fk_product_type as type, p.pmp as ppmp, p.price, p.price_ttc,"; $sql.= " ps.pmp, ps.reel as value"; - $sql.= " FROM ".MAIN_DB_PREFIX."product_stock ps, ".MAIN_DB_PREFIX."product p"; + $sql.= " FROM ".MAIN_DB_PREFIX."product_stock as ps, ".MAIN_DB_PREFIX."product as p"; $sql.= " WHERE ps.fk_product = p.rowid"; $sql.= " AND ps.reel <> 0"; // We do not show if stock is 0 (no product in this warehouse) $sql.= " AND ps.fk_entrepot = ".$object->id; diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index d8dda85f2fc..a8a554ca25d 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -123,14 +123,21 @@ class AllTests require_once dirname(__FILE__).'/DiscountTest.php'; $suite->addTestSuite('DiscountTest'); + require_once dirname(__FILE__).'/ContratTest.php'; + $suite->addTestSuite('ContratTest'); + + require_once dirname(__FILE__).'/FichinterTest.php'; + $suite->addTestSuite('FichinterTest'); + + require_once dirname(__FILE__).'/PropalTest.php'; + $suite->addTestSuite('PropalTest'); + require_once dirname(__FILE__).'/CommandeTest.php'; $suite->addTestSuite('CommandeTest'); require_once dirname(__FILE__).'/CommandeFournisseurTest.php'; $suite->addTestSuite('CommandeFournisseurTest'); - require_once dirname(__FILE__).'/ContratTest.php'; - $suite->addTestSuite('ContratTest'); require_once dirname(__FILE__).'/FactureTest.php'; $suite->addTestSuite('FactureTest'); require_once dirname(__FILE__).'/FactureRecTest.php'; @@ -139,8 +146,7 @@ class AllTests $suite->addTestSuite('FactureTestRounding'); require_once dirname(__FILE__).'/FactureFournisseurTest.php'; $suite->addTestSuite('FactureFournisseurTest'); - require_once dirname(__FILE__).'/PropalTest.php'; - $suite->addTestSuite('PropalTest'); + require_once dirname(__FILE__).'/UserTest.php'; $suite->addTestSuite('UserTest'); require_once dirname(__FILE__).'/UserGroupTest.php'; | ||