diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 73127f9a1f2..0ebe4f9b6ac 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3449,7 +3449,7 @@ class Facture extends CommonInvoice $clause = " WHERE"; - $sql = "SELECT f.rowid, f.date_lim_reglement as datefin"; + $sql = "SELECT f.rowid, f.date_lim_reglement as datefin,f.fk_statut"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; if (!$user->rights->societe->client->voir && !$user->societe_id) { @@ -3479,6 +3479,7 @@ class Facture extends CommonInvoice while ($obj=$this->db->fetch_object($resql)) { $generic_facture->date_lim_reglement = $this->db->jdate($obj->datefin); + $generic_facture->statut = $obj->fk_statut; $response->nbtodo++; @@ -3486,7 +3487,7 @@ class Facture extends CommonInvoice $response->nbtodolate++; } } - + return $response; } else @@ -3896,7 +3897,7 @@ class Facture extends CommonInvoice global $conf; $now = dol_now(); - + // Paid invoices have status STATUS_CLOSED if ($this->statut != Facture::STATUS_VALIDATED) return false; diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php index b7d40b2e65b..c4351e4d038 100644 --- a/htdocs/expensereport/payment/payment.php +++ b/htdocs/expensereport/payment/payment.php @@ -57,6 +57,9 @@ if ($action == 'add_payment') exit; } + $expensereport = new ExpenseReport($db); + $expensereport->fetch($chid); + $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); if (! $_POST["fk_typepayment"] > 0) @@ -85,8 +88,7 @@ if ($action == 'add_payment') { if (substr($key,0,7) == 'amount_') { - $other_chid = substr($key,7); - $amounts[$other_chid] = price2num($_POST[$key]); + $amounts[$expensereport->fk_user_author] = price2num($_POST[$key]); $total += price2num($_POST[$key]); } } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 8143871918d..306dfbbb9a7 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -339,7 +339,7 @@ class CommandeFournisseur extends CommonOrder $line->multicurrency_total_tva = $objp->multicurrency_total_tva; $line->multicurrency_total_ttc = $objp->multicurrency_total_ttc; - $this->special_line = $objp->special_line; + $this->special_code = $objp->special_code; $this->fk_parent_line = $objp->fk_parent_line; $this->rang = $objp->rang; diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php index 10edf5a82a7..090e980a9e5 100644 --- a/htdocs/install/repair.php +++ b/htdocs/install/repair.php @@ -73,6 +73,12 @@ $actiondone=1; print '
Check fields into extra table structure match table of definition. If not add column into table | |
'; //foreach($exts as $ext) //{ $sql="SELECT s.rowid, s.nom as name, s.logo FROM ".MAIN_DB_PREFIX."societe as s ORDER BY s.nom"; @@ -353,6 +363,8 @@ if ($ok && GETPOST('restore_thirdparties_logos')) $ok=0; dol_print_error($db); } + + print ' | |
Check table of linked elements and delete orphelins links | ".checkLinkedElements('propal', 'commande')." | \n"; + print '
| '.checkLinkedElements('propal', 'commande')." | ".checkLinkedElements('propal', 'facture')." | \n"; + print '
| '.checkLinkedElements('propal', 'facture')." | ".checkLinkedElements('commande', 'facture')." | \n"; + print '
| '.checkLinkedElements('commande', 'facture')." | ".checkLinkedElements('commande', 'shipping')." | \n"; + print '
| '.checkLinkedElements('commande', 'shipping')." | ".checkLinkedElements('shipping', 'delivery')." | \n"; + print '
| '.checkLinkedElements('shipping', 'delivery')." | ".checkLinkedElements('order_supplier', 'invoice_supplier')." | \n"; + print '
| '.checkLinkedElements('order_supplier', 'invoice_supplier')." | |
| Clean orphelins files into files '.$upload_dir.' | |
Clean orphelins files into files '.$upload_dir.' | |
| ';
print 'Delete orphelins file '.$file['fullname'].' '; - if (GETPOST('purge') == 2) + if (GETPOST('clean_orphelin_dir') == 'confirmed') { dol_delete_file($file['fullname'],1,1,1); dol_delete_dir(dirname($file['fullname']),1); @@ -502,6 +520,107 @@ if ($ok && GETPOST('clean_orphelin_dir')) } } +// clean_linked_elements: Check and clean linked elements +if ($ok && GETPOST('clean_product_stock_batch')) +{ + print ' | |
Clean table product_batch | |
| '.$obj->rowid.'-'.$obj->ref.'-'.$obj->fk_entrepot.' -> '.$obj->psrowid.': '.$obj->reel.' != '.$obj->reelbatch; + + // Fix + if ($obj->reel != $obj->reelbatch) + { + $methodtofix='updatestock'; + + if ($methodtofix == 'updatebatch') + { + // Method 1 + print ' -> Insert qty '.($obj->reel - $obj->reelbatch).' with lot 000000 linked to fk_product_stock='.$obj->psrowid; + if (GETPOST('clean_product_stock_batch') == 'confirmed') + { + $sql2 ="INSERT INTO ".MAIN_DB_PREFIX."product_batch(fk_product_stock, batch, qty)"; + $sql2.="VALUES(".$obj->psrowid.", '000000', ".($obj->reel - $obj->reelbatch).")"; + $resql2=$db->query($sql2); + if (! $resql2) + { + // TODO If it fails, we must make update + //$sql2 ="UPDATE ".MAIN_DB_PREFIX."product_batch"; + //$sql2.=" SET ".$obj->psrowid.", '000000', ".($obj->reel - $obj->reelbatch).")"; + //$sql2.=" WHERE fk_product_stock = ".$obj->psrowid" + } + } + } + if ($methodtofix == 'updatestock') + { + // Method 2 + print ' -> Update qty of stock with qty = '.$obj->reelbatch.' for ps.rowid = '.$obj->psrowid; + if (GETPOST('clean_product_stock_batch') == 'confirmed') + { + $error=0; + + $db->begin(); + + $sql2 ="UPDATE ".MAIN_DB_PREFIX."product_stock"; + $sql2.=" SET reel = ".$obj->reelbatch." WHERE rowid = ".$obj->psrowid; + $resql2=$db->query($sql2); + if ($resql2) + { + // We update product stock, so we must update product.stock too. + $sql3='UPDATE llx_product p SET p.stock= (SELECT SUM(ps.reel) FROM llx_product_stock ps WHERE ps.fk_product = p.rowid)'; + $resql3=$db->query($sql3); + if (! $resql3) + { + $error++; + dol_print_error($db); + } + } + else + { + $error++; + dol_print_error($db); + } + + if (!$error) $db->commit(); + else $db->rollback(); + } + } + } + + print' | |