diff --git a/htdocs/compta/facture/contact.php b/htdocs/compta/facture/contact.php index 68bfda4fcce..7a581aa7ab2 100644 --- a/htdocs/compta/facture/contact.php +++ b/htdocs/compta/facture/contact.php @@ -225,7 +225,7 @@ if ($id > 0) $head = facture_prepare_head($facture); - dolibarr_fiche_head($head, 1, $langs->trans('InvoiceCustomer')); + dolibarr_fiche_head($head, 'contact', $langs->trans('InvoiceCustomer')); /* * Facture synthese pour rappel diff --git a/htdocs/compta/facture/info.php b/htdocs/compta/facture/info.php index 4fa7c50dcc9..2e0d0b004c1 100644 --- a/htdocs/compta/facture/info.php +++ b/htdocs/compta/facture/info.php @@ -43,13 +43,12 @@ llxHeader(); $fac = new Facture($db); $fac->fetch($_GET["facid"]); $fac->info($_GET["facid"]); + $soc = new Societe($db, $fac->socidp); $soc->fetch($fac->socidp); + $head = facture_prepare_head($fac); -$hselected = 3; -if ($conf->use_preview_tabs) $hselected++; -if ($fac->mode_reglement_code == 'PRE') $hselected++; -dolibarr_fiche_head($head, $hselected, $langs->trans("InvoiceCustomer")); +dolibarr_fiche_head($head, 'info', $langs->trans("InvoiceCustomer")); print '
| '; diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php index def8f82ae69..3641a1417db 100644 --- a/htdocs/facture.class.php +++ b/htdocs/facture.class.php @@ -792,79 +792,74 @@ class Facture if ($resql) { $this->facnumber=$numfa; + dolibarr_syslog("Facture::set_valid() sql=$sql"); } else { - dolibarr_syslog("Facture::set_valid() Echec update - 10"); + dolibarr_syslog("Facture::set_valid() Echec update - 10 - sql=$sql"); dolibarr_print_error($this->db); $error++; } - /* - * Lit les avoirs / remises absolues en cours et les décrémente - */ - $remise_a_decrementee=$this->remise_absolue; - if ($remise_a_decrementee) + // On renomme repertoire facture ($this->ref = ancienne ref, $numfa = nouvelle ref) + // afin de ne pas perdre les fichiers attachés + $facref = sanitize_string($this->ref); + $dirsource = $conf->facture->dir_output.'/'.$facref; + $dirdest = $conf->facture->dir_output.'/'.$numfa; + + dolibarr_syslog("Facture::set_valid() renommage rep ".$dirsource." en ".$dirdest); + if (rename($dirsource, $dirdest)) { - $sql = 'SELECT rowid, fk_soc, datec, rc.amount_ht as amount, fk_user, description'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'societe_remise_except as rc'; - $sql.= ' WHERE rc.fk_soc ='. $this->socidp; - $sql.= ' AND fk_facture IS NULL'; - $sql.= ' ORDER BY datec'; - $resql = $this->db->query($sql) ; - if ($resql) + dolibarr_syslog("Renommage ok"); + // Suppression ancien fichier PDF dans nouveau rep + dol_delete_file($conf->facture->dir_output.'/'.$numfa.'/'.$facref.'.*'); + } + + + /* + * Tope les lignes de remises fixes avec id des lignes de facture au montant négatif + */ +/* TODO Toper les lignes de remises fixes avec id des lignes de facture au montant négatif. + + while ($i < $nurmx && $remise_a_decrementee && ! $error) { - $nurmx = $this->db->num_rows($resql); - if ($nurmx > 0) + $obj = $this->db->fetch_object($resql); + $avoir=$obj->amount; + + // On met à jour avoir comme affecté à facture + $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; + $sql.= ' SET fk_facture = '.$this->id.','; + $sql.= " amount_ht = '".price2num(min($remise_a_decrementee,$avoir))."'"; + $sql.= ' WHERE rowid ='.$obj->rowid; + dolibarr_syslog("Societe::set_valid Mise a jour avoir sql=$sql"); + if (! $this->db->query($sql)) { - $i=0; - while ($i < $nurmx && $remise_a_decrementee && ! $error) + $error++; + } + + if ($remise_a_decrementee < $avoir) + { + // L'avoir n'a pas été complètement consommée, on insère ligne du reste + $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'societe_remise_except'; + $sql.= ' (fk_soc, datec, amount_ht, fk_user, fk_facture, description) '; + $sql.= ' VALUES '; + $sql.= ' ('.$this->socidp; + $sql.= ' ,'.$obj->datec; + $sql.= " ,'".price2num($avoir - $remise_a_decrementee)."'"; + $sql.= ' ,'.$user->id; + $sql.= ' ,null'; + $sql.= " ,'".addslashes($obj->description)."'"; + $sql.= ')'; + if (! $this->db->query( $sql)) { - $obj = $this->db->fetch_object($resql); - $avoir=$obj->amount; - - // On met à jour avoir comme affecté à facture - $sql = 'UPDATE '.MAIN_DB_PREFIX.'societe_remise_except'; - $sql.= ' SET fk_facture = '.$this->id.','; - $sql.= " amount_ht = '".price2num(min($remise_a_decrementee,$avoir))."'"; - $sql.= ' WHERE rowid ='.$obj->rowid; - dolibarr_syslog("Societe::set_valid Mise a jour avoir sql=$sql"); - if (! $this->db->query($sql)) - { - $error++; - } - - if ($remise_a_decrementee < $avoir) - { - // L'avoir n'a pas été complètement consommée, on insère ligne du reste - $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'societe_remise_except'; - $sql.= ' (fk_soc, datec, amount_ht, fk_user, fk_facture, description) '; - $sql.= ' VALUES '; - $sql.= ' ('.$this->socidp; - $sql.= ' ,'.$obj->datec; - $sql.= " ,'".price2num($avoir - $remise_a_decrementee)."'"; - $sql.= ' ,'.$user->id; - $sql.= ' ,null'; - $sql.= " ,'".addslashes($obj->description)."'"; - $sql.= ')'; - if (! $this->db->query( $sql)) - { - $error++; - } - } - - $remise_a_decrementee-=min($remise_a_decrementee,$avoir); - $i++; + $error++; } } - $this->db->free($resql); + + $remise_a_decrementee-=min($remise_a_decrementee,$avoir); + $i++; } - else - { - dolibarr_syslog('Facture::set_valid() Erreur lecture Remise'); - $error++; - } - } +*/ /* diff --git a/htdocs/lib/invoice.lib.php b/htdocs/lib/invoice.lib.php index e03f7d1ae23..6ef6b9227b2 100644 --- a/htdocs/lib/invoice.lib.php +++ b/htdocs/lib/invoice.lib.php @@ -36,17 +36,19 @@ function facture_prepare_head($fac) $head[$h][0] = DOL_URL_ROOT.'/compta/facture.php?facid='.$fac->id; $head[$h][1] = $langs->trans('CardBill'); - $hselected = $h; + $head[$h][2] = 'compta'; $h++; $head[$h][0] = DOL_URL_ROOT.'/compta/facture/contact.php?facid='.$fac->id; $head[$h][1] = $langs->trans('BillContacts'); + $head[$h][2] = 'contact'; $h++; if ($conf->use_preview_tabs) { $head[$h][0] = DOL_URL_ROOT.'/compta/facture/apercu.php?facid='.$fac->id; $head[$h][1] = $langs->trans('Preview'); + $head[$h][2] = 'preview'; $h++; } @@ -54,14 +56,23 @@ function facture_prepare_head($fac) { $head[$h][0] = DOL_URL_ROOT.'/compta/facture/prelevement.php?facid='.$fac->id; $head[$h][1] = $langs->trans('StandingOrders'); + $head[$h][2] = 'standingorders'; $h++; } $head[$h][0] = DOL_URL_ROOT.'/compta/facture/note.php?facid='.$fac->id; $head[$h][1] = $langs->trans('Note'); + $head[$h][2] = 'note'; $h++; + + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/document.php?facid='.$fac->id; + $head[$h][1] = $langs->trans('Documents'); + $head[$h][2] = 'documents'; + $h++; + $head[$h][0] = DOL_URL_ROOT.'/compta/facture/info.php?facid='.$fac->id; $head[$h][1] = $langs->trans('Info'); + $head[$h][2] = 'info'; $h++; return $head; |