Debug v13

This commit is contained in:
Laurent Destailleur 2020-11-06 11:52:48 +01:00
parent ed8a0093ff
commit ac6f8e4e7c
5 changed files with 40 additions and 25 deletions

View File

@ -144,8 +144,12 @@ class Facture extends CommonInvoice
public $close_code; public $close_code;
//! Commentaire si mis a paye sans paiement complet //! Commentaire si mis a paye sans paiement complet
public $close_note; public $close_note;
//! 1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code)
/**
* 1 if invoice paid COMPLETELY, 0 otherwise (do not use it anymore, use statut and close_code)
*/
public $paye; public $paye;
//! key of module source when invoice generated from a dedicated module ('cashdesk', 'takepos', ...) //! key of module source when invoice generated from a dedicated module ('cashdesk', 'takepos', ...)
public $module_source; public $module_source;
//! key of pos source ('0', '1', ...) //! key of pos source ('0', '1', ...)

View File

@ -140,7 +140,7 @@ if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useles
if (!empty($conf->facture->enabled) && $user->rights->facture->lire) if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
{ {
$sql = "SELECT f.rowid, f.ref, f.datef as date, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.ref_client"; $sql = "SELECT f.rowid, f.ref, f.datef as date, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.ref_client";
$sql .= ", f.type"; $sql .= ", f.type, f.fk_statut as status, f.paye";
$sql .= ", s.nom as name"; $sql .= ", s.nom as name";
$sql .= ", s.rowid as socid, s.email"; $sql .= ", s.rowid as socid, s.email";
$sql .= ", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; $sql .= ", s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur";
@ -161,9 +161,9 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
$reshook = $hookmanager->executeHooks('printFieldListWhereCustomerDraft', $parameters); $reshook = $hookmanager->executeHooks('printFieldListWhereCustomerDraft', $parameters);
$sql .= $hookmanager->resPrint; $sql .= $hookmanager->resPrint;
$sql .= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, "; $sql .= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, f.fk_statut, f.paye,";
$sql .= "s.email, s.nom, s.rowid, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur"; $sql .= " s.email, s.nom, s.rowid, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur,";
$sql .= ", cc.rowid, cc.code"; $sql .= " cc.rowid, cc.code";
// Add Group from hooks // Add Group from hooks
$parameters = array(); $parameters = array();
@ -206,7 +206,8 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
$facturestatic->total_tva = $obj->total_tva; $facturestatic->total_tva = $obj->total_tva;
$facturestatic->total_ttc = $obj->total_ttc; $facturestatic->total_ttc = $obj->total_ttc;
$facturestatic->ref_client = $obj->ref_client; $facturestatic->ref_client = $obj->ref_client;
$facturestatic->statut = $facturestatic->statut = $obj->status;
$facturestatic->paye = $obj->paye;
$companystatic->id = $obj->socid; $companystatic->id = $obj->socid;
$companystatic->name = $obj->name; $companystatic->name = $obj->name;
@ -249,7 +250,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
*/ */
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire)
{ {
$sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier"; $sql = "SELECT f.ref, f.rowid, f.total_ht, f.total_tva, f.total_ttc, f.type, f.ref_supplier, f.fk_statut as status, f.paye";
$sql .= ", s.nom as name"; $sql .= ", s.nom as name";
$sql .= ", s.rowid as socid, s.email"; $sql .= ", s.rowid as socid, s.email";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur";
@ -299,6 +300,8 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
$facturesupplierstatic->total_ttc = $obj->total_ttc; $facturesupplierstatic->total_ttc = $obj->total_ttc;
$facturesupplierstatic->ref_supplier = $obj->ref_supplier; $facturesupplierstatic->ref_supplier = $obj->ref_supplier;
$facturesupplierstatic->type = $obj->type; $facturesupplierstatic->type = $obj->type;
$facturesupplierstatic->statut = $obj->status;
$facturesupplierstatic->paye = $obj->paye;
$companystatic->id = $obj->socid; $companystatic->id = $obj->socid;
$companystatic->name = $obj->name; $companystatic->name = $obj->name;
@ -346,7 +349,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
$langs->load("boxes"); $langs->load("boxes");
$facstatic = new Facture($db); $facstatic = new Facture($db);
$sql = "SELECT f.rowid, f.ref, f.fk_statut, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms"; $sql = "SELECT f.rowid, f.ref, f.fk_statut as status, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms";
$sql .= ", f.date_lim_reglement as datelimite"; $sql .= ", f.date_lim_reglement as datelimite";
$sql .= ", s.nom as name"; $sql .= ", s.nom as name";
$sql .= ", s.rowid as socid"; $sql .= ", s.rowid as socid";
@ -406,7 +409,8 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
$facturestatic->total_ht = $obj->total_ht; $facturestatic->total_ht = $obj->total_ht;
$facturestatic->total_tva = $obj->total_tva; $facturestatic->total_tva = $obj->total_tva;
$facturestatic->total_ttc = $obj->total_ttc; $facturestatic->total_ttc = $obj->total_ttc;
$facturestatic->statut = $obj->fk_statut; $facturestatic->statut = $obj->status;
$facturestatic->paye = $obj->paye;
$facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite);
$facturestatic->type = $obj->type; $facturestatic->type = $obj->type;
@ -448,7 +452,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="nowrap right">'.price($obj->total_ht).'</td>'; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="nowrap right">'.price($obj->total_ht).'</td>';
print '<td class="nowrap right">'.price($obj->total_ttc).'</td>'; print '<td class="nowrap right">'.price($obj->total_ttc).'</td>';
print '<td class="right">'.dol_print_date($db->jdate($obj->tms), 'day').'</td>'; print '<td class="right">'.dol_print_date($db->jdate($obj->tms), 'day').'</td>';
print '<td>'.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3, $obj->am).'</td>'; print '<td>'.$facstatic->getLibStatut(3, $obj->am).'</td>';
print '</tr>'; print '</tr>';
$total_ttc += $obj->total_ttc; $total_ttc += $obj->total_ttc;
@ -485,7 +489,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
$langs->load("boxes"); $langs->load("boxes");
$facstatic = new FactureFournisseur($db); $facstatic = new FactureFournisseur($db);
$sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.tms, ff.paye"; $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut as status, ff.libelle, ff.total_ht, ff.total_tva, ff.total_ttc, ff.tms, ff.paye";
$sql .= ", s.nom as name"; $sql .= ", s.nom as name";
$sql .= ", s.rowid as socid"; $sql .= ", s.rowid as socid";
$sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.email"; $sql .= ", s.code_fournisseur, s.code_compta_fournisseur, s.email";
@ -543,6 +547,8 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
$facstatic->total_ht = $obj->total_ht; $facstatic->total_ht = $obj->total_ht;
$facstatic->total_tva = $obj->total_tva; $facstatic->total_tva = $obj->total_tva;
$facstatic->total_ttc = $obj->total_ttc; $facstatic->total_ttc = $obj->total_ttc;
$facstatic->statut = $obj->status;
$facstatic->paye = $obj->paye;
$thirdpartystatic->id = $obj->socid; $thirdpartystatic->id = $obj->socid;
$thirdpartystatic->name = $obj->name; $thirdpartystatic->name = $obj->name;
@ -565,7 +571,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="right">'.price($obj->total_ht).'</td>'; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="right">'.price($obj->total_ht).'</td>';
print '<td class="nowrap right">'.price($obj->total_ttc).'</td>'; print '<td class="nowrap right">'.price($obj->total_ttc).'</td>';
print '<td class="right">'.dol_print_date($db->jdate($obj->tms), 'day').'</td>'; print '<td class="right">'.dol_print_date($db->jdate($obj->tms), 'day').'</td>';
print '<td>'.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3).'</td>'; print '<td>'.$facstatic->getLibStatut(3).'</td>';
print '</tr>'; print '</tr>';
$total += $obj->total_ht; $total += $obj->total_ht;
$total_ttc += $obj->total_ttc; $total_ttc += $obj->total_ttc;
@ -791,7 +797,7 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user
$sql .= ", s.nom as name, s.email"; $sql .= ", s.nom as name, s.email";
$sql .= ", s.rowid as socid"; $sql .= ", s.rowid as socid";
$sql .= ", s.code_client, s.code_compta"; $sql .= ", s.code_client, s.code_compta";
$sql .= ", c.rowid, c.ref, c.facture, c.fk_statut, c.total_ht, c.tva as total_tva, c.total_ttc,"; $sql .= ", c.rowid, c.ref, c.facture, c.fk_statut as status, c.total_ht, c.tva as total_tva, c.total_ttc,";
$sql .= " cc.rowid as country_id, cc.code as country_code"; $sql .= " cc.rowid as country_id, cc.code as country_code";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT JOIN ".MAIN_DB_PREFIX."c_country as cc ON cc.rowid = s.fk_pays";
if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@ -865,7 +871,8 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user
$commandestatic->id = $obj->rowid; $commandestatic->id = $obj->rowid;
$commandestatic->ref = $obj->ref; $commandestatic->ref = $obj->ref;
$commandestatic->statut = $obj->fk_statut; $commandestatic->statut = $obj->status;
$commandestatic->billed = $obj->facture;
print '<tr class="oddeven">'; print '<tr class="oddeven">';
print '<td class="nowrap">'; print '<td class="nowrap">';
@ -892,7 +899,7 @@ if (!empty($conf->facture->enabled) && !empty($conf->commande->enabled) && $user
if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="right">'.price($obj->total_ht).'</td>'; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="right">'.price($obj->total_ht).'</td>';
print '<td class="nowrap right">'.price($obj->total_ttc).'</td>'; print '<td class="nowrap right">'.price($obj->total_ttc).'</td>';
print '<td class="nowrap right">'.price($obj->total_ttc - $obj->tot_fttc).'</td>'; print '<td class="nowrap right">'.price($obj->total_ttc - $obj->tot_fttc).'</td>';
print '<td>'.$commandestatic->LibStatut($obj->fk_statut, $obj->facture, 3).'</td>'; print '<td>'.$commandestatic->getLibStatut(3).'</td>';
print '</tr>'; print '</tr>';
$tot_ht += $obj->total_ht; $tot_ht += $obj->total_ht;
$tot_ttc += $obj->total_ttc; $tot_ttc += $obj->total_ttc;
@ -930,7 +937,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
{ {
$facstatic = new Facture($db); $facstatic = new Facture($db);
$sql = "SELECT f.rowid, f.ref, f.fk_statut, f.datef, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms"; $sql = "SELECT f.rowid, f.ref, f.fk_statut as status, f.datef, f.type, f.total as total_ht, f.tva as total_tva, f.total_ttc, f.paye, f.tms";
$sql .= ", f.date_lim_reglement as datelimite"; $sql .= ", f.date_lim_reglement as datelimite";
$sql .= ", s.nom as name"; $sql .= ", s.nom as name";
$sql .= ", s.rowid as socid, s.email"; $sql .= ", s.rowid as socid, s.email";
@ -999,7 +1006,8 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
$facturestatic->total_tva = $obj->total_tva; $facturestatic->total_tva = $obj->total_tva;
$facturestatic->total_ttc = $obj->total_ttc; $facturestatic->total_ttc = $obj->total_ttc;
$facturestatic->type = $obj->type; $facturestatic->type = $obj->type;
$facturestatic->statut = $obj->fk_statut; $facturestatic->statut = $obj->status;
$facturestatic->paye = $obj->paye;
$facturestatic->date_lim_reglement = $db->jdate($obj->datelimite); $facturestatic->date_lim_reglement = $db->jdate($obj->datelimite);
$societestatic->id = $obj->socid; $societestatic->id = $obj->socid;
@ -1040,7 +1048,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="right">'.price($obj->total_ht).'</td>'; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="right">'.price($obj->total_ht).'</td>';
print '<td class="nowrap right">'.price($obj->total_ttc).'</td>'; print '<td class="nowrap right">'.price($obj->total_ttc).'</td>';
print '<td class="nowrap right">'.price($obj->am).'</td>'; print '<td class="nowrap right">'.price($obj->am).'</td>';
print '<td>'.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3, $obj->am, $obj->type).'</td>'; print '<td>'.$facstatic->getLibStatut(3, $obj->am, $obj->type).'</td>';
print '</tr>'; print '</tr>';
$total_ttc += $obj->total_ttc; $total_ttc += $obj->total_ttc;
@ -1086,7 +1094,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
{ {
$facstatic = new FactureFournisseur($db); $facstatic = new FactureFournisseur($db);
$sql = "SELECT ff.rowid, ff.ref, ff.fk_statut, ff.type, ff.libelle as label, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye"; $sql = "SELECT ff.rowid, ff.ref, ff.fk_statut as status, ff.type, ff.libelle as label, ff.total_ht, ff.total_tva, ff.total_ttc, ff.paye";
$sql .= ", ff.date_lim_reglement"; $sql .= ", ff.date_lim_reglement";
$sql .= ", s.nom as name"; $sql .= ", s.nom as name";
$sql .= ", s.rowid as socid, s.email"; $sql .= ", s.rowid as socid, s.email";
@ -1159,6 +1167,8 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
$facstatic->total_ht = $obj->total_ht; $facstatic->total_ht = $obj->total_ht;
$facstatic->total_tva = $obj->total_tva; $facstatic->total_tva = $obj->total_tva;
$facstatic->total_ttc = $obj->total_ttc; $facstatic->total_ttc = $obj->total_ttc;
$facstatic->statut = $obj->status;
$facstatic->paye = $obj->paye;
$societestatic->id = $obj->socid; $societestatic->id = $obj->socid;
$societestatic->name = $obj->name; $societestatic->name = $obj->name;
@ -1178,7 +1188,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="right">'.price($obj->total_ht).'</td>'; if (!empty($conf->global->MAIN_SHOW_HT_ON_SUMMARY)) print '<td class="right">'.price($obj->total_ht).'</td>';
print '<td class="nowrap right">'.price($obj->total_ttc).'</td>'; print '<td class="nowrap right">'.price($obj->total_ttc).'</td>';
print '<td class="nowrap right">'.price($obj->am).'</td>'; print '<td class="nowrap right">'.price($obj->am).'</td>';
print '<td>'.$facstatic->LibStatut($obj->paye, $obj->fk_statut, 3, $obj->am, $obj->type).'</td>'; print '<td>'.$facstatic->getLibStatut(3, $obj->am).'</td>';
print '</tr>'; print '</tr>';
$total += $obj->total_ht; $total += $obj->total_ht;
$total_ttc += $obj->total_ttc; $total_ttc += $obj->total_ttc;

View File

@ -518,15 +518,17 @@ abstract class CommonInvoice extends CommonObject
* @param int $status Id status * @param int $status Id status
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=long label + picto * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=long label + picto
* @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, -1 otherwise) * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, -1 otherwise)
* @param int $type Type invoice * @param int $type Type invoice. If -1, we use $this->type
* @return string Label of status * @return string Label of status
*/ */
public function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = 0) public function LibStatut($paye, $status, $mode = 0, $alreadypaid = -1, $type = -1)
{ {
// phpcs:enable // phpcs:enable
global $langs; global $langs;
$langs->load('bills'); $langs->load('bills');
if ($type == -1) $type = $this->type;
$statusType = 'status0'; $statusType = 'status0';
$prefix = 'Short'; $prefix = 'Short';
if (!$paye) { if (!$paye) {

View File

@ -123,7 +123,6 @@ class FactureFournisseur extends CommonInvoice
/** /**
* Set to 1 if the invoice is completely paid, otherwise is 0 * Set to 1 if the invoice is completely paid, otherwise is 0
* @var int * @var int
* @deprecated Use statuses stored in self::statut
*/ */
public $paye; public $paye;