From da702c65864ace843af12621adab411c3dedc8d2 Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Tue, 20 Jul 2004 08:54:43 +0000 Subject: [PATCH] Deplacement des fichiers pdf --- htdocs/compta/facture.php | 1409 +++++++++++++++++++------------------ 1 file changed, 706 insertions(+), 703 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index a024a27b9ca..56277d6b264 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -95,7 +95,7 @@ if ($_POST["action"] == 'add') $startday=''; $endday=''; if ($_POST["date_start${i}year"] && $_POST["date_start${i}month"] && $_POST["date_start${i}day"]) { - $startday=$_POST["date_start${i}year"].'-'.$_POST["date_start${i}month"].'-'.$_POST["date_start${i}day"]; + $startday=$_POST["date_start${i}year"].'-'.$_POST["date_start${i}month"].'-'.$_POST["date_start${i}day"]; } if ($_POST["date_end${i}year"] && $_POST["date_end${i}month"] && $_POST["date_end${i}day"]) { $endday=$_POST["date_end${i}year"].'-'.$_POST["date_end${i}month"].'-'.$_POST["date_end${i}day"]; @@ -178,9 +178,9 @@ if ($_POST["action"] == 'add') } else { - print "

Erreur : la facture n'a pas été créée, vérifier le numéro !"; - print "

Retour à la propale"; - print $db->error(); + print "

Erreur : la facture n'a pas été créée, vérifier le numéro !"; + print "

Retour à la propale"; + print $db->error(); } } @@ -204,7 +204,7 @@ if ($_POST["action"] == 'confirm_valid' && $_POST["confirm"] == yes && $user->ri $result = $fac->set_valid($fac->id, $user, $soc); if ($result) { - facture_pdf_create($db, $fac->id); + facture_pdf_create($db, $fac->id); } } @@ -241,15 +241,15 @@ if ($_POST["action"] == 'addligne' && $user->rights->facture->creer) $dateend=$_POST["date_endyear"].'-'.$_POST["date_endmonth"].'-'.$_POST["date_endday"]; } $result = $fac->addline($_POST["facid"], - $_POST["desc"], - $_POST["pu"], - $_POST["qty"], - $_POST["tva_tx"], - 0, - $_POST["remise_percent"], - $datestart, - $dateend - ); + $_POST["desc"], + $_POST["pu"], + $_POST["qty"], + $_POST["tva_tx"], + 0, + $_POST["remise_percent"], + $datestart, + $dateend + ); $_GET["facid"]=$_POST["facid"]; // Pour réaffichage de la fiche en cours d'édition } @@ -304,72 +304,72 @@ if ($_POST["action"] == 'send' || $_POST["action"] == 'relance') $fac = new Facture($db,"",$_POST["facid"]); if ( $fac->fetch($_POST["facid"]) ) { - $file = FAC_OUTPUTDIR . "/" . $fac->ref . "/" . $fac->ref . ".pdf"; + $file = FAC_OUTPUTDIR . "/" . $fac->ref . "/" . $fac->ref . ".pdf"; - if (is_readable($file)) - { + if (is_readable($file)) + { - if ($_POST["sendto"]) { - // Le destinataire a été fourni via le champ libre - $sendto = $_POST["sendto"]; - $sendtoid = 0; - } - elseif ($_POST["destinataire"]) { - // Le destinataire a été fourni via la liste déroulante - $soc = new Societe($db, $fac->socidp); - $sendto = $soc->contact_get_email($_POST["destinataire"]); - $sendtoid = $_POST["destinataire"]; - } - - if (strlen($sendto)) - { - if ($_POST["action"] == 'send') { - $subject = "Facture $fac->ref"; - $actioncode=9; - $actionmsg="Envoyée à $sendto"; - $actionmsg2="Envoi Facture par mail"; - } - if ($_POST["action"] == 'relance') { - $subject = "Relance facture $fac->ref"; - $actioncode=10; - $actionmsg="Relance envoyée à $sendto"; - $actionmsg2="Relance Facture par mail"; - } - $message = $_POST["message"]; - $filename = $fac->ref.".pdf"; + if ($_POST["sendto"]) { + // Le destinataire a été fourni via le champ libre + $sendto = $_POST["sendto"]; + $sendtoid = 0; + } + elseif ($_POST["destinataire"]) { + // Le destinataire a été fourni via la liste déroulante + $soc = new Societe($db, $fac->socidp); + $sendto = $soc->contact_get_email($_POST["destinataire"]); + $sendtoid = $_POST["destinataire"]; + } + + if (strlen($sendto)) + { + if ($_POST["action"] == 'send') { + $subject = "Facture $fac->ref"; + $actioncode=9; + $actionmsg="Envoyée à $sendto"; + $actionmsg2="Envoi Facture par mail"; + } + if ($_POST["action"] == 'relance') { + $subject = "Relance facture $fac->ref"; + $actioncode=10; + $actionmsg="Relance envoyée à $sendto"; + $actionmsg2="Relance Facture par mail"; + } + $message = $_POST["message"]; + $filename = $fac->ref.".pdf"; - $replyto = $_POST["replytoname"] . " <".$_POST["replytomail"] .">"; + $replyto = $_POST["replytoname"] . " <".$_POST["replytomail"] .">"; - // Envoi de la facture - $mailfile = new CMailFile($subject,$sendto,$replyto,$message,array ($file),array ("application/pdf"),array ($filename)); + // Envoi de la facture + $mailfile = new CMailFile($subject,$sendto,$replyto,$message,array ($file),array ("application/pdf"),array ($filename)); - if ( $mailfile->sendfile() ) - { - $sendto = htmlentities($sendto); + if ( $mailfile->sendfile() ) + { + $sendto = htmlentities($sendto); - $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm (datea,fk_action,fk_soc,note,fk_facture, fk_contact,fk_user_author, label, percent) VALUES (now(), '$actioncode' ,'$fac->socidp' ,'$actionmsg','$fac->id','$sendtoid','$user->id', '$actionmsg2',100);"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm (datea,fk_action,fk_soc,note,fk_facture, fk_contact,fk_user_author, label, percent) VALUES (now(), '$actioncode' ,'$fac->socidp' ,'$actionmsg','$fac->id','$sendtoid','$user->id', '$actionmsg2',100);"; - if (! $db->query($sql) ) - { - print $db->error(); - print "

$sql

"; - } - } - else - { - print "!! erreur d'envoi
$sendto
$replyto
$filename"; - } - } - else - { - dolibarr_syslog("Le mail du destinataire est vide"); - } - + if (! $db->query($sql) ) + { + print $db->error(); + print "

$sql

"; + } } - else + else { - dolibarr_syslog("Impossible de lire :".$file); - } + print "!! erreur d'envoi
$sendto
$replyto
$filename"; + } + } + else + { + dolibarr_syslog("Le mail du destinataire est vide"); + } + + } + else + { + dolibarr_syslog("Impossible de lire :".$file); + } } else { @@ -540,8 +540,8 @@ if ($_GET["action"] == 'create') print ''; print ''; - if ($conf->service->enabled) { - print ''; + if ($conf->service->enabled) { + print ''; } for ($i = 1 ; $i <= $NBLINES ; $i++) { @@ -550,13 +550,13 @@ if ($_GET["action"] == 'create') print ''; print ''; // Si le module service est actif, on propose des dates de début et fin à la ligne - if ($conf->service->enabled) { - print ''; + print ''; } print "\n"; } @@ -789,738 +789,741 @@ else } print " "; - print '"; + print "\n"; + } + print "
Services/Produits prédéfinisQuan.Remise     Si produit de type service à durée limitée
Si produit de type service à durée limitée
% '; + if ($conf->service->enabled) { + print ''; print 'Du '; - print $html->select_date('',"date_start$i",0,0,1); + print $html->select_date('',"date_start$i",0,0,1); print ' au '; print $html->select_date('',"date_end$i",0,0,1); - print '
'; + print ''; /* * Paiements */ - print 'Paiements :
'; - $sql = "SELECT ".$db->pdate("datep")." as dp, pf.amount,"; - $sql .= "c.libelle as paiement_type, p.num_paiement, p.rowid"; - $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as c, ".MAIN_DB_PREFIX."paiement_facture as pf"; - $sql .= " WHERE pf.fk_facture = ".$fac->id." AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid"; - $sql .= " ORDER BY dp DESC"; + print 'Paiements :
'; + $sql = "SELECT ".$db->pdate("datep")." as dp, pf.amount,"; + $sql .= "c.libelle as paiement_type, p.num_paiement, p.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."c_paiement as c, ".MAIN_DB_PREFIX."paiement_facture as pf"; + $sql .= " WHERE pf.fk_facture = ".$fac->id." AND p.fk_paiement = c.id AND pf.fk_paiement = p.rowid"; + $sql .= " ORDER BY dp DESC"; - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows(); - $i = 0; $total = 0; - echo ''; - print ''; - print ""; + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows(); + $i = 0; $total = 0; + echo '
DateTypeMontant 
'; + print ''; + print ""; - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object( $i); - $var=!$var; - print "\n"; - print "\n"; - print '\n"; - print ""; - $totalpaye += $objp->amount; - $i++; - } + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object( $i); + $var=!$var; + print "\n"; + print "\n"; + print '\n"; + print ""; + $totalpaye += $objp->amount; + $i++; + } - if ($fac->paye == 0) - { - print "\n"; - print "\n"; + if ($fac->paye == 0) + { + print "\n"; + print "\n"; - $resteapayer = $fac->total_ttc - $totalpaye; + $resteapayer = $fac->total_ttc - $totalpaye; - print ""; - print "\n"; - } - print "
DateTypeMontant 
"; - print ''.img_file().''; - print " ".strftime("%d %B %Y",$objp->dp)."$objp->paiement_type $objp->num_paiement'.price($objp->amount)."".MAIN_MONNAIE."
"; + print ''.img_file().''; + print " ".strftime("%d %B %Y",$objp->dp)."$objp->paiement_type $objp->num_paiement'.price($objp->amount)."".MAIN_MONNAIE."
Total déjà payé:".price($totalpaye)."".MAIN_MONNAIE."
Facturé :".price($fac->total_ttc)."".MAIN_MONNAIE."
Total déjà payé:".price($totalpaye)."".MAIN_MONNAIE."
Facturé :".price($fac->total_ttc)."".MAIN_MONNAIE."
Reste à payer :".price($resteapayer)."".MAIN_MONNAIE."
"; - $db->free(); - } else { - print $db->error(); - } + print "
Reste à payer :".price($resteapayer)."".MAIN_MONNAIE."
"; + $db->free(); + } else { + print $db->error(); + } - print ""; + print ""; - print "Auteur$author->fullname"; + print "Auteur$author->fullname"; - print 'Remise globale'; - print ''.$fac->remise_percent.''; - print '%'; + print 'Remise globale'; + print ''.$fac->remise_percent.''; + print '%'; - print 'Montant HT'; - print ''.price($fac->total_ht).''; - print ''.MAIN_MONNAIE.' HT'; + print 'Montant HT'; + print ''.price($fac->total_ht).''; + print ''.MAIN_MONNAIE.' HT'; - print 'TVA'.price($fac->total_tva).''; - print ''.MAIN_MONNAIE.''; - print 'Montant TTC'.price($fac->total_ttc).''; - print ''.MAIN_MONNAIE.' TTC'; - print 'Statut'.($fac->get_libstatut()).''; - if ($fac->note) - { - print 'Note : '.nl2br($fac->note).""; - } - else { + print 'TVA'.price($fac->total_tva).''; + print ''.MAIN_MONNAIE.''; + print 'Montant TTC'.price($fac->total_ttc).''; + print ''.MAIN_MONNAIE.' TTC'; + print 'Statut'.($fac->get_libstatut()).''; + if ($fac->note) + { + print 'Note : '.nl2br($fac->note).""; + } + else { print ' '; - } - - print "
"; - - if ($fac->brouillon == 1 && $user->rights->facture->creer) - { - print '
'; - print ''; - print '
Remise'; - print '%'; - print ''; - print '
'; } - /* - * Lignes de factures - * - */ - $sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_taux, l.remise_percent, l.subprice, ".$db->pdate("l.date_start")." as date_start, ".$db->pdate("l.date_end")." as date_end "; - $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l WHERE l.fk_facture = $fac->id ORDER BY l.rowid"; + print "
"; - $result = $db->query($sql); - if ($result) - { - $num_lignes = $db->num_rows(); - $i = 0; $total = 0; - - echo ''; - if ($num_lignes) - { - print ""; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - $var=True; - while ($i < $num_lignes) - { - $objp = $db->fetch_object( $i); - $var=!$var; - print ""; - if ($objp->fk_product > 0) - { - print ''; - } - else - { - print "\n"; - } + if ($fac->brouillon == 1 && $user->rights->facture->creer) + { + print ''; + print ''; + print '
DescriptionTvaP.U. HTQuantitéRemiseMontant HT  
'.stripslashes(nl2br($objp->description)).''; - if ($objp->date_start) { print " (Du ".dolibarr_print_date($objp->date_start)." au ".dolibarr_print_date($objp->date_end).")"; } - print '".stripslashes(nl2br($objp->description)); - if ($objp->date_start) { print " (Du ".dolibarr_print_date($objp->date_start)." au ".dolibarr_print_date($objp->date_end).")"; } - print "
Remise'; + print '%'; + print ''; + print '
'; + } - print ''.$objp->tva_taux.' %'; - print ''.price($objp->subprice)."\n"; - print ''.$objp->qty.''; - if ($objp->remise_percent > 0) - { - print ''.$objp->remise_percent." %\n"; - } - else - { - print ' '; - } - print ''.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)."\n"; + /* + * Lignes de factures + * + */ + $sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_taux, l.remise_percent, l.subprice, ".$db->pdate("l.date_start")." as date_start, ".$db->pdate("l.date_end")." as date_end "; + $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l WHERE l.fk_facture = $fac->id ORDER BY l.rowid"; + + $result = $db->query($sql); + if ($result) + { + $num_lignes = $db->num_rows(); + $i = 0; $total = 0; - // Icone d'edition et suppression - if ($fac->statut == 0 && $user->rights->facture->creer) - { - print ''; - print img_edit(); - print ''; - print ''; - print img_delete(); - print ''; - } - else - { - print '  '; - } - print ""; + echo ''; + if ($num_lignes) + { + print ""; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + $var=True; + while ($i < $num_lignes) + { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + if ($objp->fk_product > 0) + { + print ''; + } + else + { + print "\n"; + } + + print ''; + print '\n"; + print ''; + if ($objp->remise_percent > 0) + { + print '\n"; + } + else + { + print ''; + } + print '\n"; + + // Icone d'edition et suppression + if ($fac->statut == 0 && $user->rights->facture->creer) + { + print ''; + print ''; + } + else + { + print ''; + } + print ""; - // Update ligne de facture - if ($_GET["action"] == 'editline' && $_GET["rowid"] == $objp->rowid) - { - print ""; - print ''; - print ''; - print ''; - print ""; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print '' . "\n"; - if ($conf->service->enabled) { - print ""; - print ''; - print '' . "\n"; - } - print "\n"; - } + // Update ligne de facture + if ($_GET["action"] == 'editline' && $_GET["rowid"] == $objp->rowid) + { + print ""; + print ''; + print ''; + print ''; + print ""; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '' . "\n"; + if ($conf->service->enabled) { + print ""; + print ''; + print '' . "\n"; + } + print "\n"; + } - $total = $total + ($objp->qty * $objp->price); - $i++; - } + $total = $total + ($objp->qty * $objp->price); + $i++; + } - $db->free(); - // print "
DescriptionTvaP.U. HTQuantitéRemiseMontant HT  
'.stripslashes(nl2br($objp->description)).''; + if ($objp->date_start) { print " (Du ".dolibarr_print_date($objp->date_start)." au ".dolibarr_print_date($objp->date_end).")"; } + print '".stripslashes(nl2br($objp->description)); + if ($objp->date_start) { print " (Du ".dolibarr_print_date($objp->date_start)." au ".dolibarr_print_date($objp->date_end).")"; } + print "'.$objp->tva_taux.' %'.price($objp->subprice)."'.$objp->qty.''.$objp->remise_percent." % '.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)."'; + print img_edit(); + print ''; + print img_delete(); + print '  
'; - //print $html->select_tva("tva_tx",$objp->tva_taux); - print "$objp->tva_taux %"; // Taux tva dépend du produit, donc on ne doit pas pouvoir le changer ici - print ' %
Si produit de type service à durée limitée: Du '; - print $html->select_date($objp->date_start,"date_start",0,0,$objp->date_start?0:1); - print ' au '; - print $html->select_date($objp->date_end,"date_end",0,0,$objp->date_end?0:1); - print '
'; + //print $html->select_tva("tva_tx",$objp->tva_taux); + print "$objp->tva_taux %"; // Taux tva dépend du produit, donc on ne doit pas pouvoir le changer ici + print ' %
Si produit de type service à durée limitée: Du '; + print $html->select_date($objp->date_start,"date_start",0,0,$objp->date_start?0:1); + print ' au '; + print $html->select_date($objp->date_end,"date_end",0,0,$objp->date_end?0:1); + print '
"; - } - else - { - print "Erreur : ".$db->error()."
".$sql; - } + $db->free(); + // print ""; + } + else + { + print "Erreur : ".$db->error()."
".$sql; + } - /* - * Ajouter une ligne - * - */ - if ($fac->statut == 0 && $user->rights->facture->creer) - { + /* + * Ajouter une ligne + * + */ + if ($fac->statut == 0 && $user->rights->facture->creer) + { - print "
"; - print ""; - print 'Description'; - print 'Tva'; - print 'P.U. HT'; - print 'Quantité'; - print 'Remise'; - print ' '; - print ' '; - print ' '; - print "\n"; - print ''; - print ''; - print ''; - print ''; - print $html->select_tva("tva_tx",$conf->defaulttx); - print ''; - print ''; - print ''; - print ' %'; - print ''; - if ($conf->service->enabled) { - print ''; - print 'Si produit de type service à durée limitée: Du '; - print $html->select_date('',"date_start",0,0,1); + print ""; + print ""; + print 'Description'; + print 'Tva'; + print 'P.U. HT'; + print 'Quantité'; + print 'Remise'; + print ' '; + print ' '; + print ' '; + print "\n"; + print ''; + print ''; + print ''; + print ''; + print $html->select_tva("tva_tx",$conf->defaulttx); + print ''; + print ''; + print ''; + print ' %'; + print ''; + if ($conf->service->enabled) { + print ''; + print 'Si produit de type service à durée limitée: Du '; + print $html->select_date('',"date_start",0,0,1); print ' au '; print $html->select_date('',"date_end",0,0,1); print ''; - } - print ''; - print "
"; - } - print "
\n"; + } + print ''; + print ""; + } + print "
\n"; - /* - * Fin Ajout ligne - * - */ - print ''; - if ($user->societe_id == 0 && $_GET["action"] <> 'valid') - { - print "
\n"; + /* + * Fin Ajout ligne + * + */ + print '
'; + if ($user->societe_id == 0 && $_GET["action"] <> 'valid') + { + print "
\n"; - // Valider - if ($fac->statut == 0 && $num_lignes > 0) - { - if ($user->rights->facture->valider) - { - print 'Valider'; - } + // Valider + if ($fac->statut == 0 && $num_lignes > 0) + { + if ($user->rights->facture->valider) + { + print 'Valider'; + } + } + else + { + // Générer + if ($fac->statut == 1 && ($fac->paye == 0 || $user->admin) && $user->rights->facture->creer) + { + if ($fac->paye == 0) + { + print "id&action=pdf\">Générer le PDF"; + } + else + { + print "id&action=pdf\">Regénérer le PDF"; + } + } } - else - { - // Générer - if ($fac->statut == 1 && ($fac->paye == 0 || $user->admin) && $user->rights->facture->creer) - { - if ($fac->paye == 0) - { - print "id&action=pdf\">Générer le PDF"; - } - else - { - print "id&action=pdf\">Regénérer le PDF"; - } - } - } - // Supprimer - if ($fac->statut == 0 && $user->rights->facture->supprimer) - { - print "id&action=delete\">Supprimer"; - } + // Supprimer + if ($fac->statut == 0 && $user->rights->facture->supprimer) + { + print "id&action=delete\">Supprimer"; + } - // Envoyer - if ($fac->statut == 1 && $user->rights->facture->envoyer) - { - print "id&action=presend\">Envoyer"; - } + // Envoyer + if ($fac->statut == 1 && $user->rights->facture->envoyer) + { + print "id&action=presend\">Envoyer"; + } - // Envoyer une relance - if ($fac->statut == 1 && price($resteapayer) > 0 && $user->rights->facture->envoyer) - { - print "id&action=prerelance\">Envoyer relance"; - } + // Envoyer une relance + if ($fac->statut == 1 && price($resteapayer) > 0 && $user->rights->facture->envoyer) + { + print "id&action=prerelance\">Envoyer relance"; + } - // Emettre paiement - if ($fac->statut == 1 && price($resteapayer) > 0 && $user->rights->facture->paiement) - { - print "id."&action=create\">Emettre paiement"; - } + // Emettre paiement + if ($fac->statut == 1 && price($resteapayer) > 0 && $user->rights->facture->paiement) + { + print "id."&action=create\">Emettre paiement"; + } - // Classer 'payé' - if ($fac->statut == 1 && price($resteapayer) <= 0 - && $fac->paye == 0 && $user->rights->facture->paiement) - { - print "id&action=payed\">Classer 'Payée'"; - } + // Classer 'payé' + if ($fac->statut == 1 && price($resteapayer) <= 0 + && $fac->paye == 0 && $user->rights->facture->paiement) + { + print "id&action=payed\">Classer 'Payée'"; + } - // Classer 'annulée' (possible si validée et aucun paiement n'a encore eu lieu) - if ($fac->statut == 1 && $fac->paye == 0 && $totalpaye == 0 && $user->rights->facture->paiement) - { - print "id&action=canceled\">Classer 'Annulée'"; - } + // Classer 'annulée' (possible si validée et aucun paiement n'a encore eu lieu) + if ($fac->statut == 1 && $fac->paye == 0 && $totalpaye == 0 && $user->rights->facture->paiement) + { + print "id&action=canceled\">Classer 'Annulée'"; + } - // Récurrente - if (! defined("FACTURE_DISABLE_RECUR")) // Possibilité de désactiver les factures récurrentes - { - if ($fac->statut > 0) - { - print 'Récurrente'; - } - } + // Récurrente + if (! defined("FACTURE_DISABLE_RECUR")) // Possibilité de désactiver les factures récurrentes + { + if ($fac->statut > 0) + { + print 'Récurrente'; + } + } - print "
"; + print ""; - } - print "

\n"; + } + print "

\n"; - /* - * Documents générés - * - */ - $file = FAC_OUTPUTDIR . "/" . $fac->ref . "/" . $fac->ref . ".pdf"; + /* + * Documents générés + * + */ + $file = FAC_OUTPUTDIR . "/" . $fac->ref . "/" . $fac->ref . ".pdf"; - print ""; + print "\n"; + print ''; + print ''; + print ""; + $i++; + } + print "
"; + print "
"; - if (file_exists($file)) - { - print_titre("Documents"); - print ''; + if (file_exists($file)) + { + $encfile = urlencode($file); + print_titre("Documents"); + print '
'; - print ""; - print ''; - print ''; - print ''; - print ''; + print ""; + + print ''; + + print ''; + print ''; + print ''; - print "
Facture PDFref."/".$fac->ref.'.pdf">'.$fac->ref.'.pdf'.filesize($file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
Facture PDF'.$fac->ref.'.pdf'.filesize($file). ' bytes'.strftime("%d %b %Y %H:%M:%S",filemtime($file)).'
\n"; - } + print "
\n"; + } - print '
'; + print ''; - /* - * Liste des actions propres aux document - * - */ - $sql = "SELECT ".$db->pdate("a.datea")." as da, a.note, code "; - $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."user as u "; - $sql .= " WHERE a.fk_user_author = u.rowid and a.fk_soc = $fac->socidp AND a.fk_action in (9,10) AND a.fk_facture = $fac->id"; + /* + * Liste des actions propres aux document + * + */ + $sql = "SELECT ".$db->pdate("a.datea")." as da, a.note, code "; + $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."user as u "; + $sql .= " WHERE a.fk_user_author = u.rowid and a.fk_soc = $fac->socidp AND a.fk_action in (9,10) AND a.fk_facture = $fac->id"; - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows(); - if ($num) - { - print_titre("Actions sur les documents"); + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows(); + if ($num) + { + print_titre("Actions sur les documents"); - $i = 0; $total = 0; - print ''; - print "\n"; + $i = 0; $total = 0; + print '
DateActionPar
'; + print "\n"; - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object( $i); - $var=!$var; - print ""; - print "\n"; - print ''; - print ''; - print ""; - $i++; - } - print "
DateActionPar
".dolibarr_print_date($objp->da)."'.stripslashes($objp->note).''.$objp->code.'
"; - } - } - else - { - print $db->error(); - } + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object( $i); + $var=!$var; + print "
".dolibarr_print_date($objp->da)."'.stripslashes($objp->note).''.$objp->code.'
"; + } + } + else + { + print $db->error(); + } - print ""; + print ""; - /* - * - * - */ - if ($_GET["action"] == 'classer') - { - print "

id\">\n"; - print ''; - print ''; - print ''; - print '"; + print '
Projet'; + /* + * + * + */ + if ($_GET["action"] == 'classer') + { + print "

id\">\n"; + print ''; + print ''; + print ''; + print '"; - print '
Projet'; - $proj = new Project($db); - $html->select_array("projetid",$proj->liste_array($soc->id)); + $proj = new Project($db); + $html->select_array("projetid",$proj->liste_array($soc->id)); - print "

'; - } - /* - * - * - */ - if ($_GET["action"] == 'presend') - { - $replytoname = $user->fullname; - $from_name = $replytoname; + print "

'; + } + /* + * + * + */ + if ($_GET["action"] == 'presend') + { + $replytoname = $user->fullname; + $from_name = $replytoname; - $replytomail = $user->email; - $from_mail = $replytomail; + $replytomail = $user->email; + $from_mail = $replytomail; - print "
\n"; - print ''; - print ''; - print ''; - print ''; - print '
'; + print "\n"; + print ''; + print ''; + print ''; + print ''; + print '
'; - print_titre("Envoyer la facture par mail"); - print ""; - print ""; - print ""; - print '
Expéditeur$from_name$from_mail  
Répondre à$replytoname$replytomail  
Destinataire'; + print_titre("Envoyer la facture par mail"); + print ""; + print ""; + print ""; + print '"; + $form = new Form($db); + $form->select_array("destinataire",$soc->contact_email_array()); + print " ou email\">"; - print '"; + print '"; - print "
Expéditeur$from_name$from_mail  
Répondre à$replytoname$replytomail  
Destinataire'; - $form = new Form($db); - $form->select_array("destinataire",$soc->contact_email_array()); - print " ou email\">
Message'; - print "
Message'; + print "

\n"; + print "

\n"; - print "
\n"; - } + print "
\n"; + } - if ($_GET["action"] == 'prerelance') - { - $replytoname = $user->fullname; - $from_name = $replytoname; + if ($_GET["action"] == 'prerelance') + { + $replytoname = $user->fullname; + $from_name = $replytoname; - $replytomail = $user->email; - $from_mail = $replytomail; + $replytomail = $user->email; + $from_mail = $replytomail; - print "
\n"; - print ''; - print ''; - print ''; - print ''; - print '
'; + print "\n"; + print ''; + print ''; + print ''; + print ''; + print '
'; - print_titre("Envoyer une relance par mail"); - print ""; - print ""; - print ""; - print '
Expéditeur$from_name$from_mail  
Répondre à$replytoname$replytomail  
Destinataire'; + print_titre("Envoyer une relance par mail"); + print ""; + print ""; + print ""; + print '"; + $form = new Form($db); + $form->select_array("destinataire",$soc->contact_email_array()); + print " ou email\">"; - print '"; + print '"; - print "
Expéditeur$from_name$from_mail  
Répondre à$replytoname$replytomail  
Destinataire'; - $form = new Form($db); - $form->select_array("destinataire",$soc->contact_email_array()); - print " ou email\">
Message'; - print "
Message'; + print "

\n"; + print "

\n"; - print "
\n"; - } + print "
\n"; + } - /* - * Propales - */ + /* + * Propales + */ - $sql = "SELECT ".$db->pdate("p.datep")." as dp, p.price, p.ref, p.rowid as propalid"; - $sql .= " FROM ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."fa_pr as fp WHERE fp.fk_propal = p.rowid AND fp.fk_facture = $fac->id"; + $sql = "SELECT ".$db->pdate("p.datep")." as dp, p.price, p.ref, p.rowid as propalid"; + $sql .= " FROM ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."fa_pr as fp WHERE fp.fk_propal = p.rowid AND fp.fk_facture = $fac->id"; - $result = $db->query($sql); - if ($result) - { - $num = $db->num_rows(); - if ($num) - { - $i = 0; $total = 0; - print "

"; - if ($num >1) - { - print_titre("Propositions commerciales associées"); - } - else - { - print_titre("Proposition commerciale associée"); - } + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows(); + if ($num) + { + $i = 0; $total = 0; + print "

"; + if ($num >1) + { + print_titre("Propositions commerciales associées"); + } + else + { + print_titre("Proposition commerciale associée"); + } - print ''; - print ''; - print ""; - print ""; - print ''; - print "\n"; + print '
NuméroDatePrix
'; + print ''; + print ""; + print ""; + print ''; + print "\n"; - $var=True; - while ($i < $num) - { - $objp = $db->fetch_object( $i); - $var=!$var; - print ""; - print "\n"; - print "\n"; - print ''; - print ""; - $total = $total + $objp->price; - $i++; - } - print "\n"; - print "
NuméroDatePrix
propalid\">$objp->ref".strftime("%d %B %Y",$objp->dp)."'.price($objp->price).'
Total : ".price($total)." $_MONNAIE HT
"; - } - } else { - print $db->error(); - } - } - else - { - /* Facture non trouvée */ - print "Facture inexistante ou accés refusé"; - } - } else { - /*************************************************************************** - * * - * Mode Liste * - * * - ***************************************************************************/ - if ($page == -1) - { - $page = 0 ; - } + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print "propalid\">$objp->ref\n"; + print "".strftime("%d %B %Y",$objp->dp)."\n"; + print ''.price($objp->price).''; + print ""; + $total = $total + $objp->price; + $i++; + } + print "Total : ".price($total)." $_MONNAIE HT\n"; + print ""; + } + } else { + print $db->error(); + } + } + else + { + /* Facture non trouvée */ + print "Facture inexistante ou accés refusé"; + } + } else { + /*************************************************************************** + * * + * Mode Liste * + * * + ***************************************************************************/ + if ($page == -1) + { + $page = 0 ; + } - if ($user->rights->facture->lire) - { - $limit = $conf->liste_limit; - $offset = $limit * $page ; + if ($user->rights->facture->lire) + { + $limit = $conf->liste_limit; + $offset = $limit * $page ; - if ($sortorder == "") - $sortorder="DESC"; + if ($sortorder == "") + $sortorder="DESC"; - if ($sortfield == "") - $sortfield="f.datef"; + if ($sortfield == "") + $sortfield="f.datef"; - $sql = "SELECT s.nom,s.idp,f.facnumber,f.total,f.total_ttc,".$db->pdate("f.datef")." as df, f.paye as paye, f.rowid as facid, f.fk_statut, sum(pf.amount) as am"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f left join ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture WHERE f.fk_soc = s.idp"; + $sql = "SELECT s.nom,s.idp,f.facnumber,f.total,f.total_ttc,".$db->pdate("f.datef")." as df, f.paye as paye, f.rowid as facid, f.fk_statut, sum(pf.amount) as am"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f left join ".MAIN_DB_PREFIX."paiement_facture as pf on f.rowid=pf.fk_facture WHERE f.fk_soc = s.idp"; - if ($socidp) - $sql .= " AND s.idp = $socidp"; + if ($socidp) + $sql .= " AND s.idp = $socidp"; - if ($month > 0) - $sql .= " AND date_format(f.datef, '%m') = $month"; + if ($month > 0) + $sql .= " AND date_format(f.datef, '%m') = $month"; - if ($_GET["filtre"]) - { - $filtrearr = split(",", $_GET["filtre"]); - foreach ($filtrearr as $fil) - { - $filt = split(":", $fil); - $sql .= " AND " . $filt[0] . " = " . $filt[1]; - } - } + if ($_GET["filtre"]) + { + $filtrearr = split(",", $_GET["filtre"]); + foreach ($filtrearr as $fil) + { + $filt = split(":", $fil); + $sql .= " AND " . $filt[0] . " = " . $filt[1]; + } + } - if ($year > 0) - $sql .= " AND date_format(f.datef, '%Y') = $year"; + if ($year > 0) + $sql .= " AND date_format(f.datef, '%Y') = $year"; - if (strlen($_POST["sf_ref"]) > 0) - { - $sql .= " AND f.facnumber like '%".$_POST["sf_ref"] . "%'"; - } + if (strlen($_POST["sf_ref"]) > 0) + { + $sql .= " AND f.facnumber like '%".$_POST["sf_ref"] . "%'"; + } - $sql .= " GROUP BY f.facnumber"; + $sql .= " GROUP BY f.facnumber"; - $sql .= " ORDER BY "; - $listfield=split(',',$sortfield); - foreach ($listfield as $key => $value) { + $sql .= " ORDER BY "; + $listfield=split(',',$sortfield); + foreach ($listfield as $key => $value) { $sql.="$listfield[$key] $sortorder,"; - } - $sql .= " f.rowid DESC "; + } + $sql .= " f.rowid DESC "; - $sql .= $db->plimit($limit,$offset); + $sql .= $db->plimit($limit,$offset); - $result = $db->query($sql); - } - if ($result) - { - $num = $db->num_rows(); - print_barre_liste("Factures clients",$page,$_SERVER["PHP_SELF"],"&socidp=$socidp",$sortfield,$sortorder,'',$num); + $result = $db->query($sql); + } + if ($result) + { + $num = $db->num_rows(); + print_barre_liste("Factures clients",$page,$_SERVER["PHP_SELF"],"&socidp=$socidp",$sortfield,$sortorder,'',$num); - $i = 0; - print ''; - print ''; - print ''; - print "\n"; + $i = 0; + print '
'; - print_liste_field_titre("Numéro",$_SERVER["PHP_SELF"],"f.facnumber","","&socidp=$socidp"); - print ''; - print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"f.datef","","&socidp=$socidp"); - print ''; - print_liste_field_titre("Société",$_SERVER["PHP_SELF"],"s.nom","","&socidp=$socidp"); - print ''; - print_liste_field_titre("Montant HT",$_SERVER["PHP_SELF"],"f.total","","&socidp=$socidp"); - print ''; - print_liste_field_titre("Montant TTC",$_SERVER["PHP_SELF"],"f.total_ttc","","&socidp=$socidp"); - print ''; - print_liste_field_titre("Reçu",$_SERVER["PHP_SELF"],"am","","&socidp=$socidp"); - print ''; - print_liste_field_titre("Statut",$_SERVER["PHP_SELF"],"fk_statut,paye","","&socidp=$socidp"); - print '
'; + print ''; + print ''; + print "\n"; - if ($num > 0) - { - $var=True; - $total=0; - $totalrecu=0; + if ($num > 0) + { + $var=True; + $total=0; + $totalrecu=0; - while ($i < min($num,$limit)) - { - $objp = $db->fetch_object($i); - $var=!$var; + while ($i < min($num,$limit)) + { + $objp = $db->fetch_object($i); + $var=!$var; - print ""; - if ($objp->paye) - { - $class = "normal"; - } - else - { - if ($objp->fk_statut == 0) - { - $class = "normal"; - } - else - { - $class = "impayee"; - } - } + print ""; + if ($objp->paye) + { + $class = "normal"; + } + else + { + if ($objp->fk_statut == 0) + { + $class = "normal"; + } + else + { + $class = "impayee"; + } + } - print '\n"; + print '\n"; - if ($objp->df > 0 ) - { - print "\n"; - } - else - { - print "\n"; - } - print ''; + print strftime("%d",$objp->df)."\n"; + print ' '; + print substr(strftime("%B",$objp->df),0,3)."\n"; + print ' '; + print strftime("%Y",$objp->df)."\n"; + } + else + { + print "\n"; + } + print ''; - print ""; - print ""; - print ""; - // Affiche statut de la facture - if (! $objp->paye) - { - if ($objp->fk_statut == 0) - { - print ''; - } - elseif ($objp->fk_statut == 3) - { - print ''; - } - else - { - print ''; - } - } - else - { - print ''; - } + print ""; + print ""; + print ""; + // Affiche statut de la facture + if (! $objp->paye) + { + if ($objp->fk_statut == 0) + { + print ''; + } + elseif ($objp->fk_statut == 3) + { + print ''; + } + else + { + print ''; + } + } + else + { + print ''; + } - print "\n"; - $total+=$objp->total; - $total_ttc+=$objp->total_ttc; - $totalrecu+=$objp->am; - $i++; - } + print "\n"; + $total+=$objp->total; + $total_ttc+=$objp->total_ttc; + $totalrecu+=$objp->am; + $i++; + } - if ($num <= $limit) { - // Print total + if ($num <= $limit) { + // Print total print ""; print ""; - print ""; + print ""; print ""; print ""; print ''; print "\n"; - } - } + } + } - print "
'; + print_liste_field_titre("Numéro",$_SERVER["PHP_SELF"],"f.facnumber","","&socidp=$socidp"); + print ''; + print_liste_field_titre("Date",$_SERVER["PHP_SELF"],"f.datef","","&socidp=$socidp"); + print ''; + print_liste_field_titre("Société",$_SERVER["PHP_SELF"],"s.nom","","&socidp=$socidp"); + print ''; + print_liste_field_titre("Montant HT",$_SERVER["PHP_SELF"],"f.total","","&socidp=$socidp"); + print ''; + print_liste_field_titre("Montant TTC",$_SERVER["PHP_SELF"],"f.total_ttc","","&socidp=$socidp"); + print ''; + print_liste_field_titre("Reçu",$_SERVER["PHP_SELF"],"am","","&socidp=$socidp"); + print ''; + print_liste_field_titre("Statut",$_SERVER["PHP_SELF"],"fk_statut,paye","","&socidp=$socidp"); + print '
'.img_file()." \n"; - print ''.$objp->facnumber."'.img_file()." \n"; + print ''.$objp->facnumber.""; - $y = strftime("%Y",$objp->df); - $m = strftime("%m",$objp->df); + if ($objp->df > 0 ) + { + print ""; + $y = strftime("%Y",$objp->df); + $m = strftime("%m",$objp->df); - print strftime("%d",$objp->df)."\n"; - print ' '; - print substr(strftime("%B",$objp->df),0,3)."\n"; - print ' '; - print strftime("%Y",$objp->df)."!!!'.$objp->nom.'!!!'.$objp->nom.'".price($objp->total)."".price($objp->total_ttc)."".price($objp->am)."brouillonannulée'.($objp->am?"commencé":"impayée").'payée".price($objp->total)."".price($objp->total_ttc)."".price($objp->am)."brouillonannulée'.($objp->am?"commencé":"impayée").'payée
Total : ".price($total)."".price($total)."".price($total_ttc)."".price($totalrecu)." 
"; - $db->free(); - } - else - { - print $db->error() . "
" . $sql; - } - } + print ""; + $db->free(); + } + else + { + print $db->error() . "
" . $sql; + } + } }