Ajout possibilit de mettre des documents sur les factures

This commit is contained in:
Laurent Destailleur 2006-06-07 22:18:30 +00:00
parent 4aa4b5682d
commit d3ad176b82
4 changed files with 70 additions and 65 deletions

View File

@ -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

View File

@ -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 '<table width="100%"><tr><td>';

View File

@ -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++;
}
}
*/
/*

View File

@ -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;